// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gax;
extern crate gaxi;
extern crate iam_v1;
extern crate lazy_static;
extern crate longrunning;
extern crate lro;
extern crate reqwest;
extern crate rpc;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// A backup of a Cloud Spanner database.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Backup {
    /// Required for the
    /// [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]
    /// operation. Name of the database from which this backup was created. This
    /// needs to be in the same instance as the backup. Values are of the form
    /// `projects/<project>/instances/<instance>/databases/<database>`.
    ///
    /// [google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]: crate::client::DatabaseAdmin::create_backup
    pub database: std::string::String,

    /// The backup will contain an externally consistent copy of the database at
    /// the timestamp specified by `version_time`. If `version_time` is not
    /// specified, the system will set `version_time` to the `create_time` of the
    /// backup.
    pub version_time: std::option::Option<wkt::Timestamp>,

    /// Required for the
    /// [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]
    /// operation. The expiration time of the backup, with microseconds
    /// granularity that must be at least 6 hours and at most 366 days
    /// from the time the CreateBackup request is processed. Once the `expire_time`
    /// has passed, the backup is eligible to be automatically deleted by Cloud
    /// Spanner to free the resources used by the backup.
    ///
    /// [google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]: crate::client::DatabaseAdmin::create_backup
    pub expire_time: std::option::Option<wkt::Timestamp>,

    /// Output only for the
    /// [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]
    /// operation. Required for the
    /// [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup]
    /// operation.
    ///
    /// A globally unique identifier for the backup which cannot be
    /// changed. Values are of the form
    /// `projects/<project>/instances/<instance>/backups/[a-z][a-z0-9_\-]*[a-z0-9]`
    /// The final segment of the name must be between 2 and 60 characters
    /// in length.
    ///
    /// The backup is stored in the location(s) specified in the instance
    /// configuration of the instance containing the backup, identified
    /// by the prefix of the backup name of the form
    /// `projects/<project>/instances/<instance>`.
    ///
    /// [google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]: crate::client::DatabaseAdmin::create_backup
    /// [google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup]: crate::client::DatabaseAdmin::update_backup
    pub name: std::string::String,

    /// Output only. The time the
    /// [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]
    /// request is received. If the request does not specify `version_time`, the
    /// `version_time` of the backup will be equivalent to the `create_time`.
    ///
    /// [google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]: crate::client::DatabaseAdmin::create_backup
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Size of the backup in bytes.
    pub size_bytes: i64,

    /// Output only. The number of bytes that will be freed by deleting this
    /// backup. This value will be zero if, for example, this backup is part of an
    /// incremental backup chain and younger backups in the chain require that we
    /// keep its data. For backups not in an incremental backup chain, this is
    /// always the size of the backup. This value may change if backups on the same
    /// chain get created, deleted or expired.
    pub freeable_size_bytes: i64,

    /// Output only. For a backup in an incremental backup chain, this is the
    /// storage space needed to keep the data that has changed since the previous
    /// backup. For all other backups, this is always the size of the backup. This
    /// value may change if backups on the same chain get deleted or expired.
    ///
    /// This field can be used to calculate the total storage space used by a set
    /// of backups. For example, the total space used by all backups of a database
    /// can be computed by summing up this field.
    pub exclusive_size_bytes: i64,

    /// Output only. The current state of the backup.
    pub state: crate::model::backup::State,

    /// Output only. The names of the restored databases that reference the backup.
    /// The database names are of
    /// the form `projects/<project>/instances/<instance>/databases/<database>`.
    /// Referencing databases may exist in different instances. The existence of
    /// any referencing database prevents the backup from being deleted. When a
    /// restored database from the backup enters the `READY` state, the reference
    /// to the backup is removed.
    pub referencing_databases: std::vec::Vec<std::string::String>,

    /// Output only. The encryption information for the backup.
    pub encryption_info: std::option::Option<crate::model::EncryptionInfo>,

    /// Output only. The encryption information for the backup, whether it is
    /// protected by one or more KMS keys. The information includes all Cloud
    /// KMS key versions used to encrypt the backup. The `encryption_status' field
    /// inside of each `EncryptionInfo` is not populated. At least one of the key
    /// versions must be available for the backup to be restored. If a key version
    /// is revoked in the middle of a restore, the restore behavior is undefined.
    pub encryption_information: std::vec::Vec<crate::model::EncryptionInfo>,

    /// Output only. The database dialect information for the backup.
    pub database_dialect: crate::model::DatabaseDialect,

    /// Output only. The names of the destination backups being created by copying
    /// this source backup. The backup names are of the form
    /// `projects/<project>/instances/<instance>/backups/<backup>`.
    /// Referencing backups may exist in different instances. The existence of
    /// any referencing backup prevents the backup from being deleted. When the
    /// copy operation is done (either successfully completed or cancelled or the
    /// destination backup is deleted), the reference to the backup is removed.
    pub referencing_backups: std::vec::Vec<std::string::String>,

    /// Output only. The max allowed expiration time of the backup, with
    /// microseconds granularity. A backup's expiration time can be configured in
    /// multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or
    /// copying an existing backup, the expiration time specified must be
    /// less than `Backup.max_expire_time`.
    pub max_expire_time: std::option::Option<wkt::Timestamp>,

    /// Output only. List of backup schedule URIs that are associated with
    /// creating this backup. This is only applicable for scheduled backups, and
    /// is empty for on-demand backups.
    ///
    /// To optimize for storage, whenever possible, multiple schedules are
    /// collapsed together to create one backup. In such cases, this field captures
    /// the list of all backup schedule URIs that are associated with creating
    /// this backup. If collapsing is not done, then this field captures the
    /// single backup schedule URI associated with creating this backup.
    pub backup_schedules: std::vec::Vec<std::string::String>,

    /// Output only. Populated only for backups in an incremental backup chain.
    /// Backups share the same chain id if and only if they belong to the same
    /// incremental backup chain. Use this field to determine which backups are
    /// part of the same incremental backup chain. The ordering of backups in the
    /// chain can be determined by ordering the backup `version_time`.
    pub incremental_backup_chain_id: std::string::String,

    /// Output only. Data deleted at a time older than this is guaranteed not to be
    /// retained in order to support this backup. For a backup in an incremental
    /// backup chain, this is the version time of the oldest backup that exists or
    /// ever existed in the chain. For all other backups, this is the version time
    /// of the backup. This field can be used to understand what data is being
    /// retained by the backup system.
    pub oldest_version_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The instance partition(s) storing the backup.
    ///
    /// This is the same as the list of the instance partition(s) that the database
    /// had footprint in at the backup's `version_time`.
    pub instance_partitions: std::vec::Vec<crate::model::BackupInstancePartition>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Backup {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [database][crate::model::Backup::database].
    pub fn set_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.database = v.into();
        self
    }

    /// Sets the value of [version_time][crate::model::Backup::version_time].
    pub fn set_version_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.version_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [version_time][crate::model::Backup::version_time].
    pub fn set_or_clear_version_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.version_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [expire_time][crate::model::Backup::expire_time].
    pub fn set_expire_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.expire_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [expire_time][crate::model::Backup::expire_time].
    pub fn set_or_clear_expire_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.expire_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [name][crate::model::Backup::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [create_time][crate::model::Backup::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::Backup::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [size_bytes][crate::model::Backup::size_bytes].
    pub fn set_size_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.size_bytes = v.into();
        self
    }

    /// Sets the value of [freeable_size_bytes][crate::model::Backup::freeable_size_bytes].
    pub fn set_freeable_size_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.freeable_size_bytes = v.into();
        self
    }

    /// Sets the value of [exclusive_size_bytes][crate::model::Backup::exclusive_size_bytes].
    pub fn set_exclusive_size_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.exclusive_size_bytes = v.into();
        self
    }

    /// Sets the value of [state][crate::model::Backup::state].
    pub fn set_state<T: std::convert::Into<crate::model::backup::State>>(mut self, v: T) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [referencing_databases][crate::model::Backup::referencing_databases].
    pub fn set_referencing_databases<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.referencing_databases = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [encryption_info][crate::model::Backup::encryption_info].
    pub fn set_encryption_info<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::EncryptionInfo>,
    {
        self.encryption_info = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [encryption_info][crate::model::Backup::encryption_info].
    pub fn set_or_clear_encryption_info<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::EncryptionInfo>,
    {
        self.encryption_info = v.map(|x| x.into());
        self
    }

    /// Sets the value of [encryption_information][crate::model::Backup::encryption_information].
    pub fn set_encryption_information<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::EncryptionInfo>,
    {
        use std::iter::Iterator;
        self.encryption_information = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [database_dialect][crate::model::Backup::database_dialect].
    pub fn set_database_dialect<T: std::convert::Into<crate::model::DatabaseDialect>>(
        mut self,
        v: T,
    ) -> Self {
        self.database_dialect = v.into();
        self
    }

    /// Sets the value of [referencing_backups][crate::model::Backup::referencing_backups].
    pub fn set_referencing_backups<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.referencing_backups = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [max_expire_time][crate::model::Backup::max_expire_time].
    pub fn set_max_expire_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.max_expire_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [max_expire_time][crate::model::Backup::max_expire_time].
    pub fn set_or_clear_max_expire_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.max_expire_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [backup_schedules][crate::model::Backup::backup_schedules].
    pub fn set_backup_schedules<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.backup_schedules = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [incremental_backup_chain_id][crate::model::Backup::incremental_backup_chain_id].
    pub fn set_incremental_backup_chain_id<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.incremental_backup_chain_id = v.into();
        self
    }

    /// Sets the value of [oldest_version_time][crate::model::Backup::oldest_version_time].
    pub fn set_oldest_version_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.oldest_version_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [oldest_version_time][crate::model::Backup::oldest_version_time].
    pub fn set_or_clear_oldest_version_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.oldest_version_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [instance_partitions][crate::model::Backup::instance_partitions].
    pub fn set_instance_partitions<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::BackupInstancePartition>,
    {
        use std::iter::Iterator;
        self.instance_partitions = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for Backup {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.Backup"
    }
}

/// Defines additional types related to [Backup].
pub mod backup {
    #[allow(unused_imports)]
    use super::*;

    /// Indicates the current state of the backup.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum State {
        /// Not specified.
        Unspecified,
        /// The pending backup is still being created. Operations on the
        /// backup may fail with `FAILED_PRECONDITION` in this state.
        Creating,
        /// The backup is complete and ready for use.
        Ready,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [State::value] or
        /// [State::name].
        UnknownValue(state::UnknownValue),
    }

    #[doc(hidden)]
    pub mod state {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl State {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Creating => std::option::Option::Some(1),
                Self::Ready => std::option::Option::Some(2),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
                Self::Creating => std::option::Option::Some("CREATING"),
                Self::Ready => std::option::Option::Some("READY"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for State {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for State {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for State {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Creating,
                2 => Self::Ready,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for State {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STATE_UNSPECIFIED" => Self::Unspecified,
                "CREATING" => Self::Creating,
                "READY" => Self::Ready,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for State {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Creating => serializer.serialize_i32(1),
                Self::Ready => serializer.serialize_i32(2),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for State {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
                ".google.spanner.admin.database.v1.Backup.State",
            ))
        }
    }
}

/// The request for
/// [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]: crate::client::DatabaseAdmin::create_backup
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateBackupRequest {
    /// Required. The name of the instance in which the backup will be
    /// created. This must be the same instance that contains the database the
    /// backup will be created from. The backup will be stored in the
    /// location(s) specified in the instance configuration of this
    /// instance. Values are of the form
    /// `projects/<project>/instances/<instance>`.
    pub parent: std::string::String,

    /// Required. The id of the backup to be created. The `backup_id` appended to
    /// `parent` forms the full backup name of the form
    /// `projects/<project>/instances/<instance>/backups/<backup_id>`.
    pub backup_id: std::string::String,

    /// Required. The backup to create.
    pub backup: std::option::Option<crate::model::Backup>,

    /// Optional. The encryption configuration used to encrypt the backup. If this
    /// field is not specified, the backup will use the same encryption
    /// configuration as the database by default, namely
    /// [encryption_type][google.spanner.admin.database.v1.CreateBackupEncryptionConfig.encryption_type]
    /// = `USE_DATABASE_ENCRYPTION`.
    ///
    /// [google.spanner.admin.database.v1.CreateBackupEncryptionConfig.encryption_type]: crate::model::CreateBackupEncryptionConfig::encryption_type
    pub encryption_config: std::option::Option<crate::model::CreateBackupEncryptionConfig>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateBackupRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateBackupRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [backup_id][crate::model::CreateBackupRequest::backup_id].
    pub fn set_backup_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.backup_id = v.into();
        self
    }

    /// Sets the value of [backup][crate::model::CreateBackupRequest::backup].
    pub fn set_backup<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Backup>,
    {
        self.backup = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [backup][crate::model::CreateBackupRequest::backup].
    pub fn set_or_clear_backup<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Backup>,
    {
        self.backup = v.map(|x| x.into());
        self
    }

    /// Sets the value of [encryption_config][crate::model::CreateBackupRequest::encryption_config].
    pub fn set_encryption_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::CreateBackupEncryptionConfig>,
    {
        self.encryption_config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [encryption_config][crate::model::CreateBackupRequest::encryption_config].
    pub fn set_or_clear_encryption_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::CreateBackupEncryptionConfig>,
    {
        self.encryption_config = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for CreateBackupRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.CreateBackupRequest"
    }
}

/// Metadata type for the operation returned by
/// [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]: crate::client::DatabaseAdmin::create_backup
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateBackupMetadata {
    /// The name of the backup being created.
    pub name: std::string::String,

    /// The name of the database the backup is created from.
    pub database: std::string::String,

    /// The progress of the
    /// [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]
    /// operation.
    ///
    /// [google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]: crate::client::DatabaseAdmin::create_backup
    pub progress: std::option::Option<crate::model::OperationProgress>,

    /// The time at which cancellation of this operation was received.
    /// [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
    /// starts asynchronous cancellation on a long-running operation. The server
    /// makes a best effort to cancel the operation, but success is not guaranteed.
    /// Clients can use
    /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
    /// other methods to check whether the cancellation succeeded or whether the
    /// operation completed despite cancellation. On successful cancellation,
    /// the operation is not deleted; instead, it becomes an operation with
    /// an [Operation.error][google.longrunning.Operation.error] value with a
    /// [google.rpc.Status.code][google.rpc.Status.code] of 1,
    /// corresponding to `Code.CANCELLED`.
    ///
    /// [google.longrunning.Operation.error]: longrunning::model::Operation::result
    /// [google.rpc.Status.code]: rpc::model::Status::code
    pub cancel_time: std::option::Option<wkt::Timestamp>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateBackupMetadata {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::CreateBackupMetadata::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [database][crate::model::CreateBackupMetadata::database].
    pub fn set_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.database = v.into();
        self
    }

    /// Sets the value of [progress][crate::model::CreateBackupMetadata::progress].
    pub fn set_progress<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::OperationProgress>,
    {
        self.progress = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [progress][crate::model::CreateBackupMetadata::progress].
    pub fn set_or_clear_progress<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::OperationProgress>,
    {
        self.progress = v.map(|x| x.into());
        self
    }

    /// Sets the value of [cancel_time][crate::model::CreateBackupMetadata::cancel_time].
    pub fn set_cancel_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.cancel_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [cancel_time][crate::model::CreateBackupMetadata::cancel_time].
    pub fn set_or_clear_cancel_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.cancel_time = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for CreateBackupMetadata {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata"
    }
}

/// The request for
/// [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup]: crate::client::DatabaseAdmin::copy_backup
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CopyBackupRequest {
    /// Required. The name of the destination instance that will contain the backup
    /// copy. Values are of the form: `projects/<project>/instances/<instance>`.
    pub parent: std::string::String,

    /// Required. The id of the backup copy.
    /// The `backup_id` appended to `parent` forms the full backup_uri of the form
    /// `projects/<project>/instances/<instance>/backups/<backup>`.
    pub backup_id: std::string::String,

    /// Required. The source backup to be copied.
    /// The source backup needs to be in READY state for it to be copied.
    /// Once CopyBackup is in progress, the source backup cannot be deleted or
    /// cleaned up on expiration until CopyBackup is finished.
    /// Values are of the form:
    /// `projects/<project>/instances/<instance>/backups/<backup>`.
    pub source_backup: std::string::String,

    /// Required. The expiration time of the backup in microsecond granularity.
    /// The expiration time must be at least 6 hours and at most 366 days
    /// from the `create_time` of the source backup. Once the `expire_time` has
    /// passed, the backup is eligible to be automatically deleted by Cloud Spanner
    /// to free the resources used by the backup.
    pub expire_time: std::option::Option<wkt::Timestamp>,

    /// Optional. The encryption configuration used to encrypt the backup. If this
    /// field is not specified, the backup will use the same encryption
    /// configuration as the source backup by default, namely
    /// [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type]
    /// = `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
    ///
    /// [google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type]: crate::model::CopyBackupEncryptionConfig::encryption_type
    pub encryption_config: std::option::Option<crate::model::CopyBackupEncryptionConfig>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CopyBackupRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CopyBackupRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [backup_id][crate::model::CopyBackupRequest::backup_id].
    pub fn set_backup_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.backup_id = v.into();
        self
    }

    /// Sets the value of [source_backup][crate::model::CopyBackupRequest::source_backup].
    pub fn set_source_backup<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.source_backup = v.into();
        self
    }

    /// Sets the value of [expire_time][crate::model::CopyBackupRequest::expire_time].
    pub fn set_expire_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.expire_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [expire_time][crate::model::CopyBackupRequest::expire_time].
    pub fn set_or_clear_expire_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.expire_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [encryption_config][crate::model::CopyBackupRequest::encryption_config].
    pub fn set_encryption_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::CopyBackupEncryptionConfig>,
    {
        self.encryption_config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [encryption_config][crate::model::CopyBackupRequest::encryption_config].
    pub fn set_or_clear_encryption_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::CopyBackupEncryptionConfig>,
    {
        self.encryption_config = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for CopyBackupRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.CopyBackupRequest"
    }
}

/// Metadata type for the operation returned by
/// [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup]: crate::client::DatabaseAdmin::copy_backup
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CopyBackupMetadata {
    /// The name of the backup being created through the copy operation.
    /// Values are of the form
    /// `projects/<project>/instances/<instance>/backups/<backup>`.
    pub name: std::string::String,

    /// The name of the source backup that is being copied.
    /// Values are of the form
    /// `projects/<project>/instances/<instance>/backups/<backup>`.
    pub source_backup: std::string::String,

    /// The progress of the
    /// [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup]
    /// operation.
    ///
    /// [google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup]: crate::client::DatabaseAdmin::copy_backup
    pub progress: std::option::Option<crate::model::OperationProgress>,

    /// The time at which cancellation of CopyBackup operation was received.
    /// [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
    /// starts asynchronous cancellation on a long-running operation. The server
    /// makes a best effort to cancel the operation, but success is not guaranteed.
    /// Clients can use
    /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
    /// other methods to check whether the cancellation succeeded or whether the
    /// operation completed despite cancellation. On successful cancellation,
    /// the operation is not deleted; instead, it becomes an operation with
    /// an [Operation.error][google.longrunning.Operation.error] value with a
    /// [google.rpc.Status.code][google.rpc.Status.code] of 1,
    /// corresponding to `Code.CANCELLED`.
    ///
    /// [google.longrunning.Operation.error]: longrunning::model::Operation::result
    /// [google.rpc.Status.code]: rpc::model::Status::code
    pub cancel_time: std::option::Option<wkt::Timestamp>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CopyBackupMetadata {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::CopyBackupMetadata::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [source_backup][crate::model::CopyBackupMetadata::source_backup].
    pub fn set_source_backup<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.source_backup = v.into();
        self
    }

    /// Sets the value of [progress][crate::model::CopyBackupMetadata::progress].
    pub fn set_progress<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::OperationProgress>,
    {
        self.progress = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [progress][crate::model::CopyBackupMetadata::progress].
    pub fn set_or_clear_progress<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::OperationProgress>,
    {
        self.progress = v.map(|x| x.into());
        self
    }

    /// Sets the value of [cancel_time][crate::model::CopyBackupMetadata::cancel_time].
    pub fn set_cancel_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.cancel_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [cancel_time][crate::model::CopyBackupMetadata::cancel_time].
    pub fn set_or_clear_cancel_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.cancel_time = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for CopyBackupMetadata {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata"
    }
}

/// The request for
/// [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup]: crate::client::DatabaseAdmin::update_backup
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UpdateBackupRequest {
    /// Required. The backup to update. `backup.name`, and the fields to be updated
    /// as specified by `update_mask` are required. Other fields are ignored.
    /// Update is only supported for the following fields:
    ///
    /// * `backup.expire_time`.
    pub backup: std::option::Option<crate::model::Backup>,

    /// Required. A mask specifying which fields (e.g. `expire_time`) in the
    /// Backup resource should be updated. This mask is relative to the Backup
    /// resource, not to the request message. The field mask must always be
    /// specified; this prevents any future fields from being erased accidentally
    /// by clients that do not know about them.
    pub update_mask: std::option::Option<wkt::FieldMask>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UpdateBackupRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [backup][crate::model::UpdateBackupRequest::backup].
    pub fn set_backup<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Backup>,
    {
        self.backup = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [backup][crate::model::UpdateBackupRequest::backup].
    pub fn set_or_clear_backup<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Backup>,
    {
        self.backup = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_mask][crate::model::UpdateBackupRequest::update_mask].
    pub fn set_update_mask<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_mask][crate::model::UpdateBackupRequest::update_mask].
    pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for UpdateBackupRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.UpdateBackupRequest"
    }
}

/// The request for
/// [GetBackup][google.spanner.admin.database.v1.DatabaseAdmin.GetBackup].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.GetBackup]: crate::client::DatabaseAdmin::get_backup
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetBackupRequest {
    /// Required. Name of the backup.
    /// Values are of the form
    /// `projects/<project>/instances/<instance>/backups/<backup>`.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetBackupRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetBackupRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetBackupRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.GetBackupRequest"
    }
}

/// The request for
/// [DeleteBackup][google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackup].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackup]: crate::client::DatabaseAdmin::delete_backup
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DeleteBackupRequest {
    /// Required. Name of the backup to delete.
    /// Values are of the form
    /// `projects/<project>/instances/<instance>/backups/<backup>`.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DeleteBackupRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DeleteBackupRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for DeleteBackupRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.DeleteBackupRequest"
    }
}

/// The request for
/// [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.ListBackups]: crate::client::DatabaseAdmin::list_backups
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListBackupsRequest {
    /// Required. The instance to list backups from.  Values are of the
    /// form `projects/<project>/instances/<instance>`.
    pub parent: std::string::String,

    /// An expression that filters the list of returned backups.
    ///
    /// A filter expression consists of a field name, a comparison operator, and a
    /// value for filtering.
    /// The value must be a string, a number, or a boolean. The comparison operator
    /// must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
    /// Colon `:` is the contains operator. Filter rules are not case sensitive.
    ///
    /// The following fields in the
    /// [Backup][google.spanner.admin.database.v1.Backup] are eligible for
    /// filtering:
    ///
    /// * `name`
    /// * `database`
    /// * `state`
    /// * `create_time`  (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
    /// * `expire_time`  (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
    /// * `version_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
    /// * `size_bytes`
    /// * `backup_schedules`
    ///
    /// You can combine multiple expressions by enclosing each expression in
    /// parentheses. By default, expressions are combined with AND logic, but
    /// you can specify AND, OR, and NOT logic explicitly.
    ///
    /// Here are a few examples:
    ///
    /// * `name:Howl` - The backup's name contains the string "howl".
    /// * `database:prod` - The database's name contains the string "prod".
    /// * `state:CREATING` - The backup is pending creation.
    /// * `state:READY` - The backup is fully created and ready for use.
    /// * `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")` - The backup
    ///   name contains the string "howl" and `create_time` of the backup is before
    ///   2018-03-28T14:50:00Z.
    /// * `expire_time < \"2018-03-28T14:50:00Z\"` - The backup `expire_time` is
    ///   before 2018-03-28T14:50:00Z.
    /// * `size_bytes > 10000000000` - The backup's size is greater than 10GB
    /// * `backup_schedules:daily` - The backup is created from a schedule with
    ///   "daily" in its name.
    ///
    /// [google.spanner.admin.database.v1.Backup]: crate::model::Backup
    pub filter: std::string::String,

    /// Number of backups to be returned in the response. If 0 or
    /// less, defaults to the server's maximum allowed page size.
    pub page_size: i32,

    /// If non-empty, `page_token` should contain a
    /// [next_page_token][google.spanner.admin.database.v1.ListBackupsResponse.next_page_token]
    /// from a previous
    /// [ListBackupsResponse][google.spanner.admin.database.v1.ListBackupsResponse]
    /// to the same `parent` and with the same `filter`.
    ///
    /// [google.spanner.admin.database.v1.ListBackupsResponse]: crate::model::ListBackupsResponse
    /// [google.spanner.admin.database.v1.ListBackupsResponse.next_page_token]: crate::model::ListBackupsResponse::next_page_token
    pub page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListBackupsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListBackupsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [filter][crate::model::ListBackupsRequest::filter].
    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.filter = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListBackupsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListBackupsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListBackupsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.ListBackupsRequest"
    }
}

/// The response for
/// [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.ListBackups]: crate::client::DatabaseAdmin::list_backups
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListBackupsResponse {
    /// The list of matching backups. Backups returned are ordered by `create_time`
    /// in descending order, starting from the most recent `create_time`.
    pub backups: std::vec::Vec<crate::model::Backup>,

    /// `next_page_token` can be sent in a subsequent
    /// [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups]
    /// call to fetch more of the matching backups.
    ///
    /// [google.spanner.admin.database.v1.DatabaseAdmin.ListBackups]: crate::client::DatabaseAdmin::list_backups
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListBackupsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [backups][crate::model::ListBackupsResponse::backups].
    pub fn set_backups<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Backup>,
    {
        use std::iter::Iterator;
        self.backups = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListBackupsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListBackupsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.ListBackupsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListBackupsResponse {
    type PageItem = crate::model::Backup;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.backups
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// The request for
/// [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations]: crate::client::DatabaseAdmin::list_backup_operations
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListBackupOperationsRequest {
    /// Required. The instance of the backup operations. Values are of
    /// the form `projects/<project>/instances/<instance>`.
    pub parent: std::string::String,

    /// An expression that filters the list of returned backup operations.
    ///
    /// A filter expression consists of a field name, a
    /// comparison operator, and a value for filtering.
    /// The value must be a string, a number, or a boolean. The comparison operator
    /// must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
    /// Colon `:` is the contains operator. Filter rules are not case sensitive.
    ///
    /// The following fields in the [operation][google.longrunning.Operation]
    /// are eligible for filtering:
    ///
    /// * `name` - The name of the long-running operation
    /// * `done` - False if the operation is in progress, else true.
    /// * `metadata.@type` - the type of metadata. For example, the type string
    ///   for
    ///   [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]
    ///   is
    ///   `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`.
    /// * `metadata.<field_name>` - any field in metadata.value.
    ///   `metadata.@type` must be specified first if filtering on metadata
    ///   fields.
    /// * `error` - Error associated with the long-running operation.
    /// * `response.@type` - the type of response.
    /// * `response.<field_name>` - any field in response.value.
    ///
    /// You can combine multiple expressions by enclosing each expression in
    /// parentheses. By default, expressions are combined with AND logic, but
    /// you can specify AND, OR, and NOT logic explicitly.
    ///
    /// Here are a few examples:
    ///
    /// * `done:true` - The operation is complete.
    /// * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \
    ///   `metadata.database:prod` - Returns operations where:
    ///   * The operation's metadata type is
    ///     [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata].
    ///   * The source database name of backup contains the string "prod".
    /// * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \
    ///   `(metadata.name:howl) AND` \
    ///   `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \
    ///   `(error:*)` - Returns operations where:
    ///   * The operation's metadata type is
    ///     [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata].
    ///   * The backup name contains the string "howl".
    ///   * The operation started before 2018-03-28T14:50:00Z.
    ///   * The operation resulted in an error.
    /// * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND` \
    ///   `(metadata.source_backup:test) AND` \
    ///   `(metadata.progress.start_time < \"2022-01-18T14:50:00Z\") AND` \
    ///   `(error:*)` - Returns operations where:
    ///   * The operation's metadata type is
    ///     [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata].
    ///   * The source backup name contains the string "test".
    ///   * The operation started before 2022-01-18T14:50:00Z.
    ///   * The operation resulted in an error.
    /// * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \
    ///   `(metadata.database:test_db)) OR` \
    ///   `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata)
    ///   AND` \
    ///   `(metadata.source_backup:test_bkp)) AND` \
    ///   `(error:*)` - Returns operations where:
    ///   * The operation's metadata matches either of criteria:
    ///     * The operation's metadata type is
    ///       [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]
    ///       AND the source database name of the backup contains the string
    ///       "test_db"
    ///     * The operation's metadata type is
    ///       [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]
    ///       AND the source backup name contains the string "test_bkp"
    ///   * The operation resulted in an error.
    ///
    /// [google.longrunning.Operation]: longrunning::model::Operation
    /// [google.spanner.admin.database.v1.CopyBackupMetadata]: crate::model::CopyBackupMetadata
    /// [google.spanner.admin.database.v1.CreateBackupMetadata]: crate::model::CreateBackupMetadata
    pub filter: std::string::String,

    /// Number of operations to be returned in the response. If 0 or
    /// less, defaults to the server's maximum allowed page size.
    pub page_size: i32,

    /// If non-empty, `page_token` should contain a
    /// [next_page_token][google.spanner.admin.database.v1.ListBackupOperationsResponse.next_page_token]
    /// from a previous
    /// [ListBackupOperationsResponse][google.spanner.admin.database.v1.ListBackupOperationsResponse]
    /// to the same `parent` and with the same `filter`.
    ///
    /// [google.spanner.admin.database.v1.ListBackupOperationsResponse]: crate::model::ListBackupOperationsResponse
    /// [google.spanner.admin.database.v1.ListBackupOperationsResponse.next_page_token]: crate::model::ListBackupOperationsResponse::next_page_token
    pub page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListBackupOperationsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListBackupOperationsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [filter][crate::model::ListBackupOperationsRequest::filter].
    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.filter = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListBackupOperationsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListBackupOperationsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListBackupOperationsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.ListBackupOperationsRequest"
    }
}

/// The response for
/// [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations]: crate::client::DatabaseAdmin::list_backup_operations
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListBackupOperationsResponse {
    /// The list of matching backup [long-running
    /// operations][google.longrunning.Operation]. Each operation's name will be
    /// prefixed by the backup's name. The operation's
    /// [metadata][google.longrunning.Operation.metadata] field type
    /// `metadata.type_url` describes the type of the metadata. Operations returned
    /// include those that are pending or have completed/failed/canceled within the
    /// last 7 days. Operations returned are ordered by
    /// `operation.metadata.value.progress.start_time` in descending order starting
    /// from the most recently started operation.
    ///
    /// [google.longrunning.Operation]: longrunning::model::Operation
    /// [google.longrunning.Operation.metadata]: longrunning::model::Operation::metadata
    pub operations: std::vec::Vec<longrunning::model::Operation>,

    /// `next_page_token` can be sent in a subsequent
    /// [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations]
    /// call to fetch more of the matching metadata.
    ///
    /// [google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations]: crate::client::DatabaseAdmin::list_backup_operations
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListBackupOperationsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [operations][crate::model::ListBackupOperationsResponse::operations].
    pub fn set_operations<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<longrunning::model::Operation>,
    {
        use std::iter::Iterator;
        self.operations = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListBackupOperationsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListBackupOperationsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.ListBackupOperationsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListBackupOperationsResponse {
    type PageItem = longrunning::model::Operation;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.operations
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Information about a backup.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct BackupInfo {
    /// Name of the backup.
    pub backup: std::string::String,

    /// The backup contains an externally consistent copy of `source_database` at
    /// the timestamp specified by `version_time`. If the
    /// [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]
    /// request did not specify `version_time`, the `version_time` of the backup is
    /// equivalent to the `create_time`.
    ///
    /// [google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]: crate::client::DatabaseAdmin::create_backup
    pub version_time: std::option::Option<wkt::Timestamp>,

    /// The time the
    /// [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]
    /// request was received.
    ///
    /// [google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]: crate::client::DatabaseAdmin::create_backup
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Name of the database the backup was created from.
    pub source_database: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl BackupInfo {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [backup][crate::model::BackupInfo::backup].
    pub fn set_backup<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.backup = v.into();
        self
    }

    /// Sets the value of [version_time][crate::model::BackupInfo::version_time].
    pub fn set_version_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.version_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [version_time][crate::model::BackupInfo::version_time].
    pub fn set_or_clear_version_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.version_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [create_time][crate::model::BackupInfo::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::BackupInfo::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [source_database][crate::model::BackupInfo::source_database].
    pub fn set_source_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.source_database = v.into();
        self
    }
}

impl wkt::message::Message for BackupInfo {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.BackupInfo"
    }
}

/// Encryption configuration for the backup to create.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateBackupEncryptionConfig {
    /// Required. The encryption type of the backup.
    pub encryption_type: crate::model::create_backup_encryption_config::EncryptionType,

    /// Optional. The Cloud KMS key that will be used to protect the backup.
    /// This field should be set only when
    /// [encryption_type][google.spanner.admin.database.v1.CreateBackupEncryptionConfig.encryption_type]
    /// is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form
    /// `projects/<project>/locations/<location>/keyRings/<key_ring>/cryptoKeys/<kms_key_name>`.
    ///
    /// [google.spanner.admin.database.v1.CreateBackupEncryptionConfig.encryption_type]: crate::model::CreateBackupEncryptionConfig::encryption_type
    pub kms_key_name: std::string::String,

    /// Optional. Specifies the KMS configuration for the one or more keys used to
    /// protect the backup. Values are of the form
    /// `projects/<project>/locations/<location>/keyRings/<key_ring>/cryptoKeys/<kms_key_name>`.
    ///
    /// The keys referenced by kms_key_names must fully cover all
    /// regions of the backup's instance configuration. Some examples:
    ///
    /// * For single region instance configs, specify a single regional
    ///   location KMS key.
    /// * For multi-regional instance configs of type GOOGLE_MANAGED,
    ///   either specify a multi-regional location KMS key or multiple regional
    ///   location KMS keys that cover all regions in the instance config.
    /// * For an instance config of type USER_MANAGED, please specify only
    ///   regional location KMS keys to cover each region in the instance config.
    ///   Multi-regional location KMS keys are not supported for USER_MANAGED
    ///   instance configs.
    pub kms_key_names: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateBackupEncryptionConfig {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [encryption_type][crate::model::CreateBackupEncryptionConfig::encryption_type].
    pub fn set_encryption_type<
        T: std::convert::Into<crate::model::create_backup_encryption_config::EncryptionType>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.encryption_type = v.into();
        self
    }

    /// Sets the value of [kms_key_name][crate::model::CreateBackupEncryptionConfig::kms_key_name].
    pub fn set_kms_key_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.kms_key_name = v.into();
        self
    }

    /// Sets the value of [kms_key_names][crate::model::CreateBackupEncryptionConfig::kms_key_names].
    pub fn set_kms_key_names<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.kms_key_names = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for CreateBackupEncryptionConfig {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.CreateBackupEncryptionConfig"
    }
}

/// Defines additional types related to [CreateBackupEncryptionConfig].
pub mod create_backup_encryption_config {
    #[allow(unused_imports)]
    use super::*;

    /// Encryption types for the backup.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum EncryptionType {
        /// Unspecified. Do not use.
        Unspecified,
        /// Use the same encryption configuration as the database. This is the
        /// default option when
        /// [encryption_config][google.spanner.admin.database.v1.CreateBackupEncryptionConfig]
        /// is empty. For example, if the database is using
        /// `Customer_Managed_Encryption`, the backup will be using the same Cloud
        /// KMS key as the database.
        ///
        /// [google.spanner.admin.database.v1.CreateBackupEncryptionConfig]: crate::model::CreateBackupEncryptionConfig
        UseDatabaseEncryption,
        /// Use Google default encryption.
        GoogleDefaultEncryption,
        /// Use customer managed encryption. If specified, `kms_key_name`
        /// must contain a valid Cloud KMS key.
        CustomerManagedEncryption,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [EncryptionType::value] or
        /// [EncryptionType::name].
        UnknownValue(encryption_type::UnknownValue),
    }

    #[doc(hidden)]
    pub mod encryption_type {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl EncryptionType {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::UseDatabaseEncryption => std::option::Option::Some(1),
                Self::GoogleDefaultEncryption => std::option::Option::Some(2),
                Self::CustomerManagedEncryption => std::option::Option::Some(3),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("ENCRYPTION_TYPE_UNSPECIFIED"),
                Self::UseDatabaseEncryption => std::option::Option::Some("USE_DATABASE_ENCRYPTION"),
                Self::GoogleDefaultEncryption => {
                    std::option::Option::Some("GOOGLE_DEFAULT_ENCRYPTION")
                }
                Self::CustomerManagedEncryption => {
                    std::option::Option::Some("CUSTOMER_MANAGED_ENCRYPTION")
                }
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for EncryptionType {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for EncryptionType {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for EncryptionType {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::UseDatabaseEncryption,
                2 => Self::GoogleDefaultEncryption,
                3 => Self::CustomerManagedEncryption,
                _ => Self::UnknownValue(encryption_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for EncryptionType {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "ENCRYPTION_TYPE_UNSPECIFIED" => Self::Unspecified,
                "USE_DATABASE_ENCRYPTION" => Self::UseDatabaseEncryption,
                "GOOGLE_DEFAULT_ENCRYPTION" => Self::GoogleDefaultEncryption,
                "CUSTOMER_MANAGED_ENCRYPTION" => Self::CustomerManagedEncryption,
                _ => Self::UnknownValue(encryption_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for EncryptionType {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::UseDatabaseEncryption => serializer.serialize_i32(1),
                Self::GoogleDefaultEncryption => serializer.serialize_i32(2),
                Self::CustomerManagedEncryption => serializer.serialize_i32(3),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for EncryptionType {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<EncryptionType>::new(
                ".google.spanner.admin.database.v1.CreateBackupEncryptionConfig.EncryptionType",
            ))
        }
    }
}

/// Encryption configuration for the copied backup.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CopyBackupEncryptionConfig {
    /// Required. The encryption type of the backup.
    pub encryption_type: crate::model::copy_backup_encryption_config::EncryptionType,

    /// Optional. The Cloud KMS key that will be used to protect the backup.
    /// This field should be set only when
    /// [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type]
    /// is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form
    /// `projects/<project>/locations/<location>/keyRings/<key_ring>/cryptoKeys/<kms_key_name>`.
    ///
    /// [google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type]: crate::model::CopyBackupEncryptionConfig::encryption_type
    pub kms_key_name: std::string::String,

    /// Optional. Specifies the KMS configuration for the one or more keys used to
    /// protect the backup. Values are of the form
    /// `projects/<project>/locations/<location>/keyRings/<key_ring>/cryptoKeys/<kms_key_name>`.
    /// Kms keys specified can be in any order.
    ///
    /// The keys referenced by kms_key_names must fully cover all
    /// regions of the backup's instance configuration. Some examples:
    ///
    /// * For single region instance configs, specify a single regional
    ///   location KMS key.
    /// * For multi-regional instance configs of type GOOGLE_MANAGED,
    ///   either specify a multi-regional location KMS key or multiple regional
    ///   location KMS keys that cover all regions in the instance config.
    /// * For an instance config of type USER_MANAGED, please specify only
    ///   regional location KMS keys to cover each region in the instance config.
    ///   Multi-regional location KMS keys are not supported for USER_MANAGED
    ///   instance configs.
    pub kms_key_names: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CopyBackupEncryptionConfig {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [encryption_type][crate::model::CopyBackupEncryptionConfig::encryption_type].
    pub fn set_encryption_type<
        T: std::convert::Into<crate::model::copy_backup_encryption_config::EncryptionType>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.encryption_type = v.into();
        self
    }

    /// Sets the value of [kms_key_name][crate::model::CopyBackupEncryptionConfig::kms_key_name].
    pub fn set_kms_key_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.kms_key_name = v.into();
        self
    }

    /// Sets the value of [kms_key_names][crate::model::CopyBackupEncryptionConfig::kms_key_names].
    pub fn set_kms_key_names<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.kms_key_names = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for CopyBackupEncryptionConfig {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.CopyBackupEncryptionConfig"
    }
}

/// Defines additional types related to [CopyBackupEncryptionConfig].
pub mod copy_backup_encryption_config {
    #[allow(unused_imports)]
    use super::*;

    /// Encryption types for the backup.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum EncryptionType {
        /// Unspecified. Do not use.
        Unspecified,
        /// This is the default option for
        /// [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup]
        /// when
        /// [encryption_config][google.spanner.admin.database.v1.CopyBackupEncryptionConfig]
        /// is not specified. For example, if the source backup is using
        /// `Customer_Managed_Encryption`, the backup will be using the same Cloud
        /// KMS key as the source backup.
        ///
        /// [google.spanner.admin.database.v1.CopyBackupEncryptionConfig]: crate::model::CopyBackupEncryptionConfig
        /// [google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup]: crate::client::DatabaseAdmin::copy_backup
        UseConfigDefaultOrBackupEncryption,
        /// Use Google default encryption.
        GoogleDefaultEncryption,
        /// Use customer managed encryption. If specified, either `kms_key_name` or
        /// `kms_key_names` must contain valid Cloud KMS key(s).
        CustomerManagedEncryption,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [EncryptionType::value] or
        /// [EncryptionType::name].
        UnknownValue(encryption_type::UnknownValue),
    }

    #[doc(hidden)]
    pub mod encryption_type {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl EncryptionType {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::UseConfigDefaultOrBackupEncryption => std::option::Option::Some(1),
                Self::GoogleDefaultEncryption => std::option::Option::Some(2),
                Self::CustomerManagedEncryption => std::option::Option::Some(3),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("ENCRYPTION_TYPE_UNSPECIFIED"),
                Self::UseConfigDefaultOrBackupEncryption => {
                    std::option::Option::Some("USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION")
                }
                Self::GoogleDefaultEncryption => {
                    std::option::Option::Some("GOOGLE_DEFAULT_ENCRYPTION")
                }
                Self::CustomerManagedEncryption => {
                    std::option::Option::Some("CUSTOMER_MANAGED_ENCRYPTION")
                }
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for EncryptionType {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for EncryptionType {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for EncryptionType {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::UseConfigDefaultOrBackupEncryption,
                2 => Self::GoogleDefaultEncryption,
                3 => Self::CustomerManagedEncryption,
                _ => Self::UnknownValue(encryption_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for EncryptionType {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "ENCRYPTION_TYPE_UNSPECIFIED" => Self::Unspecified,
                "USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION" => {
                    Self::UseConfigDefaultOrBackupEncryption
                }
                "GOOGLE_DEFAULT_ENCRYPTION" => Self::GoogleDefaultEncryption,
                "CUSTOMER_MANAGED_ENCRYPTION" => Self::CustomerManagedEncryption,
                _ => Self::UnknownValue(encryption_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for EncryptionType {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::UseConfigDefaultOrBackupEncryption => serializer.serialize_i32(1),
                Self::GoogleDefaultEncryption => serializer.serialize_i32(2),
                Self::CustomerManagedEncryption => serializer.serialize_i32(3),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for EncryptionType {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<EncryptionType>::new(
                ".google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType",
            ))
        }
    }
}

/// The specification for full backups.
/// A full backup stores the entire contents of the database at a given
/// version time.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct FullBackupSpec {
    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl FullBackupSpec {
    pub fn new() -> Self {
        std::default::Default::default()
    }
}

impl wkt::message::Message for FullBackupSpec {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.FullBackupSpec"
    }
}

/// The specification for incremental backup chains.
/// An incremental backup stores the delta of changes between a previous
/// backup and the database contents at a given version time. An
/// incremental backup chain consists of a full backup and zero or more
/// successive incremental backups. The first backup created for an
/// incremental backup chain is always a full backup.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct IncrementalBackupSpec {
    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl IncrementalBackupSpec {
    pub fn new() -> Self {
        std::default::Default::default()
    }
}

impl wkt::message::Message for IncrementalBackupSpec {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.IncrementalBackupSpec"
    }
}

/// Instance partition information for the backup.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct BackupInstancePartition {
    /// A unique identifier for the instance partition. Values are of the form
    /// `projects/<project>/instances/<instance>/instancePartitions/<instance_partition_id>`
    pub instance_partition: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl BackupInstancePartition {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [instance_partition][crate::model::BackupInstancePartition::instance_partition].
    pub fn set_instance_partition<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.instance_partition = v.into();
        self
    }
}

impl wkt::message::Message for BackupInstancePartition {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.BackupInstancePartition"
    }
}

/// Defines specifications of the backup schedule.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct BackupScheduleSpec {
    /// Required.
    pub schedule_spec: std::option::Option<crate::model::backup_schedule_spec::ScheduleSpec>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl BackupScheduleSpec {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [schedule_spec][crate::model::BackupScheduleSpec::schedule_spec].
    ///
    /// Note that all the setters affecting `schedule_spec` are mutually
    /// exclusive.
    pub fn set_schedule_spec<
        T: std::convert::Into<std::option::Option<crate::model::backup_schedule_spec::ScheduleSpec>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.schedule_spec = v.into();
        self
    }

    /// The value of [schedule_spec][crate::model::BackupScheduleSpec::schedule_spec]
    /// if it holds a `CronSpec`, `None` if the field is not set or
    /// holds a different branch.
    pub fn cron_spec(&self) -> std::option::Option<&std::boxed::Box<crate::model::CrontabSpec>> {
        #[allow(unreachable_patterns)]
        self.schedule_spec.as_ref().and_then(|v| match v {
            crate::model::backup_schedule_spec::ScheduleSpec::CronSpec(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [schedule_spec][crate::model::BackupScheduleSpec::schedule_spec]
    /// to hold a `CronSpec`.
    ///
    /// Note that all the setters affecting `schedule_spec` are
    /// mutually exclusive.
    pub fn set_cron_spec<T: std::convert::Into<std::boxed::Box<crate::model::CrontabSpec>>>(
        mut self,
        v: T,
    ) -> Self {
        self.schedule_spec = std::option::Option::Some(
            crate::model::backup_schedule_spec::ScheduleSpec::CronSpec(v.into()),
        );
        self
    }
}

impl wkt::message::Message for BackupScheduleSpec {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.BackupScheduleSpec"
    }
}

/// Defines additional types related to [BackupScheduleSpec].
pub mod backup_schedule_spec {
    #[allow(unused_imports)]
    use super::*;

    /// Required.
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum ScheduleSpec {
        /// Cron style schedule specification.
        CronSpec(std::boxed::Box<crate::model::CrontabSpec>),
    }
}

/// BackupSchedule expresses the automated backup creation specification for a
/// Spanner database.
/// Next ID: 10
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct BackupSchedule {
    /// Identifier. Output only for the
    /// [CreateBackupSchedule][DatabaseAdmin.CreateBackupSchededule] operation.
    /// Required for the
    /// [UpdateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule]
    /// operation. A globally unique identifier for the backup schedule which
    /// cannot be changed. Values are of the form
    /// `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/[a-z][a-z0-9_\-]*[a-z0-9]`
    /// The final segment of the name must be between 2 and 60 characters in
    /// length.
    ///
    /// [google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule]: crate::client::DatabaseAdmin::update_backup_schedule
    pub name: std::string::String,

    /// Optional. The schedule specification based on which the backup creations
    /// are triggered.
    pub spec: std::option::Option<crate::model::BackupScheduleSpec>,

    /// Optional. The retention duration of a backup that must be at least 6 hours
    /// and at most 366 days. The backup is eligible to be automatically deleted
    /// once the retention period has elapsed.
    pub retention_duration: std::option::Option<wkt::Duration>,

    /// Optional. The encryption configuration that will be used to encrypt the
    /// backup. If this field is not specified, the backup will use the same
    /// encryption configuration as the database.
    pub encryption_config: std::option::Option<crate::model::CreateBackupEncryptionConfig>,

    /// Output only. The timestamp at which the schedule was last updated.
    /// If the schedule has never been updated, this field contains the timestamp
    /// when the schedule was first created.
    pub update_time: std::option::Option<wkt::Timestamp>,

    /// Required. Backup type spec determines the type of backup that is created by
    /// the backup schedule. Currently, only full backups are supported.
    pub backup_type_spec: std::option::Option<crate::model::backup_schedule::BackupTypeSpec>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl BackupSchedule {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::BackupSchedule::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [spec][crate::model::BackupSchedule::spec].
    pub fn set_spec<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::BackupScheduleSpec>,
    {
        self.spec = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [spec][crate::model::BackupSchedule::spec].
    pub fn set_or_clear_spec<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::BackupScheduleSpec>,
    {
        self.spec = v.map(|x| x.into());
        self
    }

    /// Sets the value of [retention_duration][crate::model::BackupSchedule::retention_duration].
    pub fn set_retention_duration<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Duration>,
    {
        self.retention_duration = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [retention_duration][crate::model::BackupSchedule::retention_duration].
    pub fn set_or_clear_retention_duration<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Duration>,
    {
        self.retention_duration = v.map(|x| x.into());
        self
    }

    /// Sets the value of [encryption_config][crate::model::BackupSchedule::encryption_config].
    pub fn set_encryption_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::CreateBackupEncryptionConfig>,
    {
        self.encryption_config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [encryption_config][crate::model::BackupSchedule::encryption_config].
    pub fn set_or_clear_encryption_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::CreateBackupEncryptionConfig>,
    {
        self.encryption_config = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_time][crate::model::BackupSchedule::update_time].
    pub fn set_update_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_time][crate::model::BackupSchedule::update_time].
    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [backup_type_spec][crate::model::BackupSchedule::backup_type_spec].
    ///
    /// Note that all the setters affecting `backup_type_spec` are mutually
    /// exclusive.
    pub fn set_backup_type_spec<
        T: std::convert::Into<std::option::Option<crate::model::backup_schedule::BackupTypeSpec>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.backup_type_spec = v.into();
        self
    }

    /// The value of [backup_type_spec][crate::model::BackupSchedule::backup_type_spec]
    /// if it holds a `FullBackupSpec`, `None` if the field is not set or
    /// holds a different branch.
    pub fn full_backup_spec(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::FullBackupSpec>> {
        #[allow(unreachable_patterns)]
        self.backup_type_spec.as_ref().and_then(|v| match v {
            crate::model::backup_schedule::BackupTypeSpec::FullBackupSpec(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [backup_type_spec][crate::model::BackupSchedule::backup_type_spec]
    /// to hold a `FullBackupSpec`.
    ///
    /// Note that all the setters affecting `backup_type_spec` are
    /// mutually exclusive.
    pub fn set_full_backup_spec<
        T: std::convert::Into<std::boxed::Box<crate::model::FullBackupSpec>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.backup_type_spec = std::option::Option::Some(
            crate::model::backup_schedule::BackupTypeSpec::FullBackupSpec(v.into()),
        );
        self
    }

    /// The value of [backup_type_spec][crate::model::BackupSchedule::backup_type_spec]
    /// if it holds a `IncrementalBackupSpec`, `None` if the field is not set or
    /// holds a different branch.
    pub fn incremental_backup_spec(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::IncrementalBackupSpec>> {
        #[allow(unreachable_patterns)]
        self.backup_type_spec.as_ref().and_then(|v| match v {
            crate::model::backup_schedule::BackupTypeSpec::IncrementalBackupSpec(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [backup_type_spec][crate::model::BackupSchedule::backup_type_spec]
    /// to hold a `IncrementalBackupSpec`.
    ///
    /// Note that all the setters affecting `backup_type_spec` are
    /// mutually exclusive.
    pub fn set_incremental_backup_spec<
        T: std::convert::Into<std::boxed::Box<crate::model::IncrementalBackupSpec>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.backup_type_spec = std::option::Option::Some(
            crate::model::backup_schedule::BackupTypeSpec::IncrementalBackupSpec(v.into()),
        );
        self
    }
}

impl wkt::message::Message for BackupSchedule {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.BackupSchedule"
    }
}

/// Defines additional types related to [BackupSchedule].
pub mod backup_schedule {
    #[allow(unused_imports)]
    use super::*;

    /// Required. Backup type spec determines the type of backup that is created by
    /// the backup schedule. Currently, only full backups are supported.
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum BackupTypeSpec {
        /// The schedule creates only full backups.
        FullBackupSpec(std::boxed::Box<crate::model::FullBackupSpec>),
        /// The schedule creates incremental backup chains.
        IncrementalBackupSpec(std::boxed::Box<crate::model::IncrementalBackupSpec>),
    }
}

/// CrontabSpec can be used to specify the version time and frequency at
/// which the backup should be created.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CrontabSpec {
    /// Required. Textual representation of the crontab. User can customize the
    /// backup frequency and the backup version time using the cron
    /// expression. The version time must be in UTC timezone.
    ///
    /// The backup will contain an externally consistent copy of the
    /// database at the version time. Allowed frequencies are 12 hour, 1 day,
    /// 1 week and 1 month. Examples of valid cron specifications:
    ///
    /// * `0 2/12 * * * ` : every 12 hours at (2, 14) hours past midnight in UTC.
    /// * `0 2,14 * * * ` : every 12 hours at (2,14) hours past midnight in UTC.
    /// * `0 2 * * * `    : once a day at 2 past midnight in UTC.
    /// * `0 2 * * 0 `    : once a week every Sunday at 2 past midnight in UTC.
    /// * `0 2 8 * * `    : once a month on 8th day at 2 past midnight in UTC.
    pub text: std::string::String,

    /// Output only. The time zone of the times in `CrontabSpec.text`. Currently
    /// only UTC is supported.
    pub time_zone: std::string::String,

    /// Output only. Schedule backups will contain an externally consistent copy
    /// of the database at the version time specified in
    /// `schedule_spec.cron_spec`. However, Spanner may not initiate the creation
    /// of the scheduled backups at that version time. Spanner will initiate
    /// the creation of scheduled backups within the time window bounded by the
    /// version_time specified in `schedule_spec.cron_spec` and version_time +
    /// `creation_window`.
    pub creation_window: std::option::Option<wkt::Duration>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CrontabSpec {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [text][crate::model::CrontabSpec::text].
    pub fn set_text<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.text = v.into();
        self
    }

    /// Sets the value of [time_zone][crate::model::CrontabSpec::time_zone].
    pub fn set_time_zone<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.time_zone = v.into();
        self
    }

    /// Sets the value of [creation_window][crate::model::CrontabSpec::creation_window].
    pub fn set_creation_window<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Duration>,
    {
        self.creation_window = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [creation_window][crate::model::CrontabSpec::creation_window].
    pub fn set_or_clear_creation_window<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Duration>,
    {
        self.creation_window = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for CrontabSpec {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.CrontabSpec"
    }
}

/// The request for
/// [CreateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackupSchedule].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.CreateBackupSchedule]: crate::client::DatabaseAdmin::create_backup_schedule
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateBackupScheduleRequest {
    /// Required. The name of the database that this backup schedule applies to.
    pub parent: std::string::String,

    /// Required. The Id to use for the backup schedule. The `backup_schedule_id`
    /// appended to `parent` forms the full backup schedule name of the form
    /// `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
    pub backup_schedule_id: std::string::String,

    /// Required. The backup schedule to create.
    pub backup_schedule: std::option::Option<crate::model::BackupSchedule>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateBackupScheduleRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateBackupScheduleRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [backup_schedule_id][crate::model::CreateBackupScheduleRequest::backup_schedule_id].
    pub fn set_backup_schedule_id<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.backup_schedule_id = v.into();
        self
    }

    /// Sets the value of [backup_schedule][crate::model::CreateBackupScheduleRequest::backup_schedule].
    pub fn set_backup_schedule<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::BackupSchedule>,
    {
        self.backup_schedule = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [backup_schedule][crate::model::CreateBackupScheduleRequest::backup_schedule].
    pub fn set_or_clear_backup_schedule<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::BackupSchedule>,
    {
        self.backup_schedule = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for CreateBackupScheduleRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.CreateBackupScheduleRequest"
    }
}

/// The request for
/// [GetBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.GetBackupSchedule].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.GetBackupSchedule]: crate::client::DatabaseAdmin::get_backup_schedule
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetBackupScheduleRequest {
    /// Required. The name of the schedule to retrieve.
    /// Values are of the form
    /// `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetBackupScheduleRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetBackupScheduleRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetBackupScheduleRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.GetBackupScheduleRequest"
    }
}

/// The request for
/// [DeleteBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackupSchedule].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackupSchedule]: crate::client::DatabaseAdmin::delete_backup_schedule
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DeleteBackupScheduleRequest {
    /// Required. The name of the schedule to delete.
    /// Values are of the form
    /// `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DeleteBackupScheduleRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DeleteBackupScheduleRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for DeleteBackupScheduleRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.DeleteBackupScheduleRequest"
    }
}

/// The request for
/// [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules]: crate::client::DatabaseAdmin::list_backup_schedules
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListBackupSchedulesRequest {
    /// Required. Database is the parent resource whose backup schedules should be
    /// listed. Values are of the form
    /// projects/\<project\>/instances/\<instance\>/databases/\<database\>
    pub parent: std::string::String,

    /// Optional. Number of backup schedules to be returned in the response. If 0
    /// or less, defaults to the server's maximum allowed page size.
    pub page_size: i32,

    /// Optional. If non-empty, `page_token` should contain a
    /// [next_page_token][google.spanner.admin.database.v1.ListBackupSchedulesResponse.next_page_token]
    /// from a previous
    /// [ListBackupSchedulesResponse][google.spanner.admin.database.v1.ListBackupSchedulesResponse]
    /// to the same `parent`.
    ///
    /// [google.spanner.admin.database.v1.ListBackupSchedulesResponse]: crate::model::ListBackupSchedulesResponse
    /// [google.spanner.admin.database.v1.ListBackupSchedulesResponse.next_page_token]: crate::model::ListBackupSchedulesResponse::next_page_token
    pub page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListBackupSchedulesRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListBackupSchedulesRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListBackupSchedulesRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListBackupSchedulesRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListBackupSchedulesRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.ListBackupSchedulesRequest"
    }
}

/// The response for
/// [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules]: crate::client::DatabaseAdmin::list_backup_schedules
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListBackupSchedulesResponse {
    /// The list of backup schedules for a database.
    pub backup_schedules: std::vec::Vec<crate::model::BackupSchedule>,

    /// `next_page_token` can be sent in a subsequent
    /// [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules]
    /// call to fetch more of the schedules.
    ///
    /// [google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules]: crate::client::DatabaseAdmin::list_backup_schedules
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListBackupSchedulesResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [backup_schedules][crate::model::ListBackupSchedulesResponse::backup_schedules].
    pub fn set_backup_schedules<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::BackupSchedule>,
    {
        use std::iter::Iterator;
        self.backup_schedules = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListBackupSchedulesResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListBackupSchedulesResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.ListBackupSchedulesResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListBackupSchedulesResponse {
    type PageItem = crate::model::BackupSchedule;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.backup_schedules
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// The request for
/// [UpdateBackupScheduleRequest][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule]: crate::client::DatabaseAdmin::update_backup_schedule
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UpdateBackupScheduleRequest {
    /// Required. The backup schedule to update. `backup_schedule.name`, and the
    /// fields to be updated as specified by `update_mask` are required. Other
    /// fields are ignored.
    pub backup_schedule: std::option::Option<crate::model::BackupSchedule>,

    /// Required. A mask specifying which fields in the BackupSchedule resource
    /// should be updated. This mask is relative to the BackupSchedule resource,
    /// not to the request message. The field mask must always be
    /// specified; this prevents any future fields from being erased
    /// accidentally.
    pub update_mask: std::option::Option<wkt::FieldMask>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UpdateBackupScheduleRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [backup_schedule][crate::model::UpdateBackupScheduleRequest::backup_schedule].
    pub fn set_backup_schedule<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::BackupSchedule>,
    {
        self.backup_schedule = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [backup_schedule][crate::model::UpdateBackupScheduleRequest::backup_schedule].
    pub fn set_or_clear_backup_schedule<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::BackupSchedule>,
    {
        self.backup_schedule = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_mask][crate::model::UpdateBackupScheduleRequest::update_mask].
    pub fn set_update_mask<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_mask][crate::model::UpdateBackupScheduleRequest::update_mask].
    pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for UpdateBackupScheduleRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.UpdateBackupScheduleRequest"
    }
}

/// Encapsulates progress related information for a Cloud Spanner long
/// running operation.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct OperationProgress {
    /// Percent completion of the operation.
    /// Values are between 0 and 100 inclusive.
    pub progress_percent: i32,

    /// Time the request was received.
    pub start_time: std::option::Option<wkt::Timestamp>,

    /// If set, the time at which this operation failed or was completed
    /// successfully.
    pub end_time: std::option::Option<wkt::Timestamp>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl OperationProgress {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [progress_percent][crate::model::OperationProgress::progress_percent].
    pub fn set_progress_percent<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.progress_percent = v.into();
        self
    }

    /// Sets the value of [start_time][crate::model::OperationProgress::start_time].
    pub fn set_start_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.start_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [start_time][crate::model::OperationProgress::start_time].
    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.start_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [end_time][crate::model::OperationProgress::end_time].
    pub fn set_end_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [end_time][crate::model::OperationProgress::end_time].
    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for OperationProgress {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.OperationProgress"
    }
}

/// Encryption configuration for a Cloud Spanner database.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct EncryptionConfig {
    /// The Cloud KMS key to be used for encrypting and decrypting
    /// the database. Values are of the form
    /// `projects/<project>/locations/<location>/keyRings/<key_ring>/cryptoKeys/<kms_key_name>`.
    pub kms_key_name: std::string::String,

    /// Specifies the KMS configuration for the one or more keys used to encrypt
    /// the database. Values are of the form
    /// `projects/<project>/locations/<location>/keyRings/<key_ring>/cryptoKeys/<kms_key_name>`.
    ///
    /// The keys referenced by kms_key_names must fully cover all
    /// regions of the database instance configuration. Some examples:
    ///
    /// * For single region database instance configs, specify a single regional
    ///   location KMS key.
    /// * For multi-regional database instance configs of type GOOGLE_MANAGED,
    ///   either specify a multi-regional location KMS key or multiple regional
    ///   location KMS keys that cover all regions in the instance config.
    /// * For a database instance config of type USER_MANAGED, please specify only
    ///   regional location KMS keys to cover each region in the instance config.
    ///   Multi-regional location KMS keys are not supported for USER_MANAGED
    ///   instance configs.
    pub kms_key_names: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl EncryptionConfig {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [kms_key_name][crate::model::EncryptionConfig::kms_key_name].
    pub fn set_kms_key_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.kms_key_name = v.into();
        self
    }

    /// Sets the value of [kms_key_names][crate::model::EncryptionConfig::kms_key_names].
    pub fn set_kms_key_names<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.kms_key_names = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for EncryptionConfig {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.EncryptionConfig"
    }
}

/// Encryption information for a Cloud Spanner database or backup.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct EncryptionInfo {
    /// Output only. The type of encryption.
    pub encryption_type: crate::model::encryption_info::Type,

    /// Output only. If present, the status of a recent encrypt/decrypt call on
    /// underlying data for this database or backup. Regardless of status, data is
    /// always encrypted at rest.
    pub encryption_status: std::option::Option<rpc::model::Status>,

    /// Output only. A Cloud KMS key version that is being used to protect the
    /// database or backup.
    pub kms_key_version: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl EncryptionInfo {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [encryption_type][crate::model::EncryptionInfo::encryption_type].
    pub fn set_encryption_type<T: std::convert::Into<crate::model::encryption_info::Type>>(
        mut self,
        v: T,
    ) -> Self {
        self.encryption_type = v.into();
        self
    }

    /// Sets the value of [encryption_status][crate::model::EncryptionInfo::encryption_status].
    pub fn set_encryption_status<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<rpc::model::Status>,
    {
        self.encryption_status = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [encryption_status][crate::model::EncryptionInfo::encryption_status].
    pub fn set_or_clear_encryption_status<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<rpc::model::Status>,
    {
        self.encryption_status = v.map(|x| x.into());
        self
    }

    /// Sets the value of [kms_key_version][crate::model::EncryptionInfo::kms_key_version].
    pub fn set_kms_key_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.kms_key_version = v.into();
        self
    }
}

impl wkt::message::Message for EncryptionInfo {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.EncryptionInfo"
    }
}

/// Defines additional types related to [EncryptionInfo].
pub mod encryption_info {
    #[allow(unused_imports)]
    use super::*;

    /// Possible encryption types.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Type {
        /// Encryption type was not specified, though data at rest remains encrypted.
        Unspecified,
        /// The data is encrypted at rest with a key that is
        /// fully managed by Google. No key version or status will be populated.
        /// This is the default state.
        GoogleDefaultEncryption,
        /// The data is encrypted at rest with a key that is
        /// managed by the customer. The active version of the key. `kms_key_version`
        /// will be populated, and `encryption_status` may be populated.
        CustomerManagedEncryption,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [Type::value] or
        /// [Type::name].
        UnknownValue(r#type::UnknownValue),
    }

    #[doc(hidden)]
    pub mod r#type {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl Type {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::GoogleDefaultEncryption => std::option::Option::Some(1),
                Self::CustomerManagedEncryption => std::option::Option::Some(2),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
                Self::GoogleDefaultEncryption => {
                    std::option::Option::Some("GOOGLE_DEFAULT_ENCRYPTION")
                }
                Self::CustomerManagedEncryption => {
                    std::option::Option::Some("CUSTOMER_MANAGED_ENCRYPTION")
                }
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for Type {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for Type {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for Type {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::GoogleDefaultEncryption,
                2 => Self::CustomerManagedEncryption,
                _ => Self::UnknownValue(r#type::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for Type {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "TYPE_UNSPECIFIED" => Self::Unspecified,
                "GOOGLE_DEFAULT_ENCRYPTION" => Self::GoogleDefaultEncryption,
                "CUSTOMER_MANAGED_ENCRYPTION" => Self::CustomerManagedEncryption,
                _ => Self::UnknownValue(r#type::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for Type {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::GoogleDefaultEncryption => serializer.serialize_i32(1),
                Self::CustomerManagedEncryption => serializer.serialize_i32(2),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for Type {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
                ".google.spanner.admin.database.v1.EncryptionInfo.Type",
            ))
        }
    }
}

/// Information about the database restore.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct RestoreInfo {
    /// The type of the restore source.
    pub source_type: crate::model::RestoreSourceType,

    /// Information about the source used to restore the database.
    pub source_info: std::option::Option<crate::model::restore_info::SourceInfo>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl RestoreInfo {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [source_type][crate::model::RestoreInfo::source_type].
    pub fn set_source_type<T: std::convert::Into<crate::model::RestoreSourceType>>(
        mut self,
        v: T,
    ) -> Self {
        self.source_type = v.into();
        self
    }

    /// Sets the value of [source_info][crate::model::RestoreInfo::source_info].
    ///
    /// Note that all the setters affecting `source_info` are mutually
    /// exclusive.
    pub fn set_source_info<
        T: std::convert::Into<std::option::Option<crate::model::restore_info::SourceInfo>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.source_info = v.into();
        self
    }

    /// The value of [source_info][crate::model::RestoreInfo::source_info]
    /// if it holds a `BackupInfo`, `None` if the field is not set or
    /// holds a different branch.
    pub fn backup_info(&self) -> std::option::Option<&std::boxed::Box<crate::model::BackupInfo>> {
        #[allow(unreachable_patterns)]
        self.source_info.as_ref().and_then(|v| match v {
            crate::model::restore_info::SourceInfo::BackupInfo(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [source_info][crate::model::RestoreInfo::source_info]
    /// to hold a `BackupInfo`.
    ///
    /// Note that all the setters affecting `source_info` are
    /// mutually exclusive.
    pub fn set_backup_info<T: std::convert::Into<std::boxed::Box<crate::model::BackupInfo>>>(
        mut self,
        v: T,
    ) -> Self {
        self.source_info =
            std::option::Option::Some(crate::model::restore_info::SourceInfo::BackupInfo(v.into()));
        self
    }
}

impl wkt::message::Message for RestoreInfo {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.RestoreInfo"
    }
}

/// Defines additional types related to [RestoreInfo].
pub mod restore_info {
    #[allow(unused_imports)]
    use super::*;

    /// Information about the source used to restore the database.
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum SourceInfo {
        /// Information about the backup used to restore the database. The backup
        /// may no longer exist.
        BackupInfo(std::boxed::Box<crate::model::BackupInfo>),
    }
}

/// A Cloud Spanner database.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Database {
    /// Required. The name of the database. Values are of the form
    /// `projects/<project>/instances/<instance>/databases/<database>`,
    /// where `<database>` is as specified in the `CREATE DATABASE`
    /// statement. This name can be passed to other API methods to
    /// identify the database.
    pub name: std::string::String,

    /// Output only. The current database state.
    pub state: crate::model::database::State,

    /// Output only. If exists, the time at which the database creation started.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Applicable only for restored databases. Contains information
    /// about the restore source.
    pub restore_info: std::option::Option<crate::model::RestoreInfo>,

    /// Output only. For databases that are using customer managed encryption, this
    /// field contains the encryption configuration for the database.
    /// For databases that are using Google default or other types of encryption,
    /// this field is empty.
    pub encryption_config: std::option::Option<crate::model::EncryptionConfig>,

    /// Output only. For databases that are using customer managed encryption, this
    /// field contains the encryption information for the database, such as
    /// all Cloud KMS key versions that are in use. The `encryption_status' field
    /// inside of each `EncryptionInfo` is not populated.
    ///
    /// For databases that are using Google default or other types of encryption,
    /// this field is empty.
    ///
    /// This field is propagated lazily from the backend. There might be a delay
    /// from when a key version is being used and when it appears in this field.
    pub encryption_info: std::vec::Vec<crate::model::EncryptionInfo>,

    /// Output only. The period in which Cloud Spanner retains all versions of data
    /// for the database. This is the same as the value of version_retention_period
    /// database option set using
    /// [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl].
    /// Defaults to 1 hour, if not set.
    ///
    /// [google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl]: crate::client::DatabaseAdmin::update_database_ddl
    pub version_retention_period: std::string::String,

    /// Output only. Earliest timestamp at which older versions of the data can be
    /// read. This value is continuously updated by Cloud Spanner and becomes stale
    /// the moment it is queried. If you are using this value to recover data, make
    /// sure to account for the time from the moment when the value is queried to
    /// the moment when you initiate the recovery.
    pub earliest_version_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The read-write region which contains the database's leader
    /// replicas.
    ///
    /// This is the same as the value of default_leader
    /// database option set using DatabaseAdmin.CreateDatabase or
    /// DatabaseAdmin.UpdateDatabaseDdl. If not explicitly set, this is empty.
    pub default_leader: std::string::String,

    /// Output only. The dialect of the Cloud Spanner Database.
    pub database_dialect: crate::model::DatabaseDialect,

    /// Whether drop protection is enabled for this database. Defaults to false,
    /// if not set. For more details, please see how to [prevent accidental
    /// database
    /// deletion](https://cloud.google.com/spanner/docs/prevent-database-deletion).
    pub enable_drop_protection: bool,

    /// Output only. If true, the database is being updated. If false, there are no
    /// ongoing update operations for the database.
    pub reconciling: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Database {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::Database::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [state][crate::model::Database::state].
    pub fn set_state<T: std::convert::Into<crate::model::database::State>>(mut self, v: T) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [create_time][crate::model::Database::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::Database::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [restore_info][crate::model::Database::restore_info].
    pub fn set_restore_info<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::RestoreInfo>,
    {
        self.restore_info = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [restore_info][crate::model::Database::restore_info].
    pub fn set_or_clear_restore_info<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::RestoreInfo>,
    {
        self.restore_info = v.map(|x| x.into());
        self
    }

    /// Sets the value of [encryption_config][crate::model::Database::encryption_config].
    pub fn set_encryption_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::EncryptionConfig>,
    {
        self.encryption_config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [encryption_config][crate::model::Database::encryption_config].
    pub fn set_or_clear_encryption_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::EncryptionConfig>,
    {
        self.encryption_config = v.map(|x| x.into());
        self
    }

    /// Sets the value of [encryption_info][crate::model::Database::encryption_info].
    pub fn set_encryption_info<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::EncryptionInfo>,
    {
        use std::iter::Iterator;
        self.encryption_info = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [version_retention_period][crate::model::Database::version_retention_period].
    pub fn set_version_retention_period<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.version_retention_period = v.into();
        self
    }

    /// Sets the value of [earliest_version_time][crate::model::Database::earliest_version_time].
    pub fn set_earliest_version_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.earliest_version_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [earliest_version_time][crate::model::Database::earliest_version_time].
    pub fn set_or_clear_earliest_version_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.earliest_version_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [default_leader][crate::model::Database::default_leader].
    pub fn set_default_leader<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.default_leader = v.into();
        self
    }

    /// Sets the value of [database_dialect][crate::model::Database::database_dialect].
    pub fn set_database_dialect<T: std::convert::Into<crate::model::DatabaseDialect>>(
        mut self,
        v: T,
    ) -> Self {
        self.database_dialect = v.into();
        self
    }

    /// Sets the value of [enable_drop_protection][crate::model::Database::enable_drop_protection].
    pub fn set_enable_drop_protection<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.enable_drop_protection = v.into();
        self
    }

    /// Sets the value of [reconciling][crate::model::Database::reconciling].
    pub fn set_reconciling<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.reconciling = v.into();
        self
    }
}

impl wkt::message::Message for Database {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.Database"
    }
}

/// Defines additional types related to [Database].
pub mod database {
    #[allow(unused_imports)]
    use super::*;

    /// Indicates the current state of the database.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum State {
        /// Not specified.
        Unspecified,
        /// The database is still being created. Operations on the database may fail
        /// with `FAILED_PRECONDITION` in this state.
        Creating,
        /// The database is fully created and ready for use.
        Ready,
        /// The database is fully created and ready for use, but is still
        /// being optimized for performance and cannot handle full load.
        ///
        /// In this state, the database still references the backup
        /// it was restore from, preventing the backup
        /// from being deleted. When optimizations are complete, the full performance
        /// of the database will be restored, and the database will transition to
        /// `READY` state.
        ReadyOptimizing,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [State::value] or
        /// [State::name].
        UnknownValue(state::UnknownValue),
    }

    #[doc(hidden)]
    pub mod state {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl State {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Creating => std::option::Option::Some(1),
                Self::Ready => std::option::Option::Some(2),
                Self::ReadyOptimizing => std::option::Option::Some(3),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
                Self::Creating => std::option::Option::Some("CREATING"),
                Self::Ready => std::option::Option::Some("READY"),
                Self::ReadyOptimizing => std::option::Option::Some("READY_OPTIMIZING"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for State {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for State {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for State {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Creating,
                2 => Self::Ready,
                3 => Self::ReadyOptimizing,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for State {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STATE_UNSPECIFIED" => Self::Unspecified,
                "CREATING" => Self::Creating,
                "READY" => Self::Ready,
                "READY_OPTIMIZING" => Self::ReadyOptimizing,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for State {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Creating => serializer.serialize_i32(1),
                Self::Ready => serializer.serialize_i32(2),
                Self::ReadyOptimizing => serializer.serialize_i32(3),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for State {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
                ".google.spanner.admin.database.v1.Database.State",
            ))
        }
    }
}

/// The request for
/// [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases]: crate::client::DatabaseAdmin::list_databases
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListDatabasesRequest {
    /// Required. The instance whose databases should be listed.
    /// Values are of the form `projects/<project>/instances/<instance>`.
    pub parent: std::string::String,

    /// Number of databases to be returned in the response. If 0 or less,
    /// defaults to the server's maximum allowed page size.
    pub page_size: i32,

    /// If non-empty, `page_token` should contain a
    /// [next_page_token][google.spanner.admin.database.v1.ListDatabasesResponse.next_page_token]
    /// from a previous
    /// [ListDatabasesResponse][google.spanner.admin.database.v1.ListDatabasesResponse].
    ///
    /// [google.spanner.admin.database.v1.ListDatabasesResponse]: crate::model::ListDatabasesResponse
    /// [google.spanner.admin.database.v1.ListDatabasesResponse.next_page_token]: crate::model::ListDatabasesResponse::next_page_token
    pub page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListDatabasesRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListDatabasesRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListDatabasesRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListDatabasesRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListDatabasesRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.ListDatabasesRequest"
    }
}

/// The response for
/// [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases]: crate::client::DatabaseAdmin::list_databases
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListDatabasesResponse {
    /// Databases that matched the request.
    pub databases: std::vec::Vec<crate::model::Database>,

    /// `next_page_token` can be sent in a subsequent
    /// [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases]
    /// call to fetch more of the matching databases.
    ///
    /// [google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases]: crate::client::DatabaseAdmin::list_databases
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListDatabasesResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [databases][crate::model::ListDatabasesResponse::databases].
    pub fn set_databases<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Database>,
    {
        use std::iter::Iterator;
        self.databases = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListDatabasesResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListDatabasesResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.ListDatabasesResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListDatabasesResponse {
    type PageItem = crate::model::Database;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.databases
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// The request for
/// [CreateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase]: crate::client::DatabaseAdmin::create_database
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateDatabaseRequest {
    /// Required. The name of the instance that will serve the new database.
    /// Values are of the form `projects/<project>/instances/<instance>`.
    pub parent: std::string::String,

    /// Required. A `CREATE DATABASE` statement, which specifies the ID of the
    /// new database.  The database ID must conform to the regular expression
    /// `[a-z][a-z0-9_\-]*[a-z0-9]` and be between 2 and 30 characters in length.
    /// If the database ID is a reserved word or if it contains a hyphen, the
    /// database ID must be enclosed in backticks (`` ` ``).
    pub create_statement: std::string::String,

    /// Optional. A list of DDL statements to run inside the newly created
    /// database. Statements can create tables, indexes, etc. These
    /// statements execute atomically with the creation of the database:
    /// if there is an error in any statement, the database is not created.
    pub extra_statements: std::vec::Vec<std::string::String>,

    /// Optional. The encryption configuration for the database. If this field is
    /// not specified, Cloud Spanner will encrypt/decrypt all data at rest using
    /// Google default encryption.
    pub encryption_config: std::option::Option<crate::model::EncryptionConfig>,

    /// Optional. The dialect of the Cloud Spanner Database.
    pub database_dialect: crate::model::DatabaseDialect,

    /// Optional. Proto descriptors used by CREATE/ALTER PROTO BUNDLE statements in
    /// 'extra_statements' above.
    /// Contains a protobuf-serialized
    /// [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto).
    /// To generate it, [install](https://grpc.io/docs/protoc-installation/) and
    /// run `protoc` with --include_imports and --descriptor_set_out. For example,
    /// to generate for moon/shot/app.proto, run
    ///
    /// ```norust
    /// $protoc  --proto_path=/app_path --proto_path=/lib_path \
    ///          --include_imports \
    ///          --descriptor_set_out=descriptors.data \
    ///          moon/shot/app.proto
    /// ```
    ///
    /// For more details, see protobuffer [self
    /// description](https://developers.google.com/protocol-buffers/docs/techniques#self-description).
    pub proto_descriptors: ::bytes::Bytes,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateDatabaseRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateDatabaseRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [create_statement][crate::model::CreateDatabaseRequest::create_statement].
    pub fn set_create_statement<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.create_statement = v.into();
        self
    }

    /// Sets the value of [extra_statements][crate::model::CreateDatabaseRequest::extra_statements].
    pub fn set_extra_statements<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.extra_statements = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [encryption_config][crate::model::CreateDatabaseRequest::encryption_config].
    pub fn set_encryption_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::EncryptionConfig>,
    {
        self.encryption_config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [encryption_config][crate::model::CreateDatabaseRequest::encryption_config].
    pub fn set_or_clear_encryption_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::EncryptionConfig>,
    {
        self.encryption_config = v.map(|x| x.into());
        self
    }

    /// Sets the value of [database_dialect][crate::model::CreateDatabaseRequest::database_dialect].
    pub fn set_database_dialect<T: std::convert::Into<crate::model::DatabaseDialect>>(
        mut self,
        v: T,
    ) -> Self {
        self.database_dialect = v.into();
        self
    }

    /// Sets the value of [proto_descriptors][crate::model::CreateDatabaseRequest::proto_descriptors].
    pub fn set_proto_descriptors<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
        self.proto_descriptors = v.into();
        self
    }
}

impl wkt::message::Message for CreateDatabaseRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.CreateDatabaseRequest"
    }
}

/// Metadata type for the operation returned by
/// [CreateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase]: crate::client::DatabaseAdmin::create_database
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateDatabaseMetadata {
    /// The database being created.
    pub database: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateDatabaseMetadata {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [database][crate::model::CreateDatabaseMetadata::database].
    pub fn set_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.database = v.into();
        self
    }
}

impl wkt::message::Message for CreateDatabaseMetadata {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.CreateDatabaseMetadata"
    }
}

/// The request for
/// [GetDatabase][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabase].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.GetDatabase]: crate::client::DatabaseAdmin::get_database
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetDatabaseRequest {
    /// Required. The name of the requested database. Values are of the form
    /// `projects/<project>/instances/<instance>/databases/<database>`.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetDatabaseRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetDatabaseRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetDatabaseRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.GetDatabaseRequest"
    }
}

/// The request for
/// [UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase]: crate::client::DatabaseAdmin::update_database
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UpdateDatabaseRequest {
    /// Required. The database to update.
    /// The `name` field of the database is of the form
    /// `projects/<project>/instances/<instance>/databases/<database>`.
    pub database: std::option::Option<crate::model::Database>,

    /// Required. The list of fields to update. Currently, only
    /// `enable_drop_protection` field can be updated.
    pub update_mask: std::option::Option<wkt::FieldMask>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UpdateDatabaseRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [database][crate::model::UpdateDatabaseRequest::database].
    pub fn set_database<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Database>,
    {
        self.database = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [database][crate::model::UpdateDatabaseRequest::database].
    pub fn set_or_clear_database<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Database>,
    {
        self.database = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_mask][crate::model::UpdateDatabaseRequest::update_mask].
    pub fn set_update_mask<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_mask][crate::model::UpdateDatabaseRequest::update_mask].
    pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for UpdateDatabaseRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.UpdateDatabaseRequest"
    }
}

/// Metadata type for the operation returned by
/// [UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase]: crate::client::DatabaseAdmin::update_database
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UpdateDatabaseMetadata {
    /// The request for
    /// [UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase].
    ///
    /// [google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase]: crate::client::DatabaseAdmin::update_database
    pub request: std::option::Option<crate::model::UpdateDatabaseRequest>,

    /// The progress of the
    /// [UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase]
    /// operation.
    ///
    /// [google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase]: crate::client::DatabaseAdmin::update_database
    pub progress: std::option::Option<crate::model::OperationProgress>,

    /// The time at which this operation was cancelled. If set, this operation is
    /// in the process of undoing itself (which is best-effort).
    pub cancel_time: std::option::Option<wkt::Timestamp>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UpdateDatabaseMetadata {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [request][crate::model::UpdateDatabaseMetadata::request].
    pub fn set_request<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::UpdateDatabaseRequest>,
    {
        self.request = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [request][crate::model::UpdateDatabaseMetadata::request].
    pub fn set_or_clear_request<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::UpdateDatabaseRequest>,
    {
        self.request = v.map(|x| x.into());
        self
    }

    /// Sets the value of [progress][crate::model::UpdateDatabaseMetadata::progress].
    pub fn set_progress<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::OperationProgress>,
    {
        self.progress = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [progress][crate::model::UpdateDatabaseMetadata::progress].
    pub fn set_or_clear_progress<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::OperationProgress>,
    {
        self.progress = v.map(|x| x.into());
        self
    }

    /// Sets the value of [cancel_time][crate::model::UpdateDatabaseMetadata::cancel_time].
    pub fn set_cancel_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.cancel_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [cancel_time][crate::model::UpdateDatabaseMetadata::cancel_time].
    pub fn set_or_clear_cancel_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.cancel_time = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for UpdateDatabaseMetadata {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.UpdateDatabaseMetadata"
    }
}

/// Enqueues the given DDL statements to be applied, in order but not
/// necessarily all at once, to the database schema at some point (or
/// points) in the future. The server checks that the statements
/// are executable (syntactically valid, name tables that exist, etc.)
/// before enqueueing them, but they may still fail upon
/// later execution (e.g., if a statement from another batch of
/// statements is applied first and it conflicts in some way, or if
/// there is some data-related problem like a `NULL` value in a column to
/// which `NOT NULL` would be added). If a statement fails, all
/// subsequent statements in the batch are automatically cancelled.
///
/// Each batch of statements is assigned a name which can be used with
/// the [Operations][google.longrunning.Operations] API to monitor
/// progress. See the
/// [operation_id][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.operation_id]
/// field for more details.
///
/// [google.longrunning.Operations]: longrunning::client::Operations
/// [google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.operation_id]: crate::model::UpdateDatabaseDdlRequest::operation_id
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UpdateDatabaseDdlRequest {
    /// Required. The database to update.
    pub database: std::string::String,

    /// Required. DDL statements to be applied to the database.
    pub statements: std::vec::Vec<std::string::String>,

    /// If empty, the new update request is assigned an
    /// automatically-generated operation ID. Otherwise, `operation_id`
    /// is used to construct the name of the resulting
    /// [Operation][google.longrunning.Operation].
    ///
    /// Specifying an explicit operation ID simplifies determining
    /// whether the statements were executed in the event that the
    /// [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl]
    /// call is replayed, or the return value is otherwise lost: the
    /// [database][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.database]
    /// and `operation_id` fields can be combined to form the
    /// [name][google.longrunning.Operation.name] of the resulting
    /// [longrunning.Operation][google.longrunning.Operation]:
    /// `<database>/operations/<operation_id>`.
    ///
    /// `operation_id` should be unique within the database, and must be
    /// a valid identifier: `[a-z][a-z0-9_]*`. Note that
    /// automatically-generated operation IDs always begin with an
    /// underscore. If the named operation already exists,
    /// [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl]
    /// returns `ALREADY_EXISTS`.
    ///
    /// [google.longrunning.Operation]: longrunning::model::Operation
    /// [google.longrunning.Operation.name]: longrunning::model::Operation::name
    /// [google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl]: crate::client::DatabaseAdmin::update_database_ddl
    /// [google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.database]: crate::model::UpdateDatabaseDdlRequest::database
    pub operation_id: std::string::String,

    /// Optional. Proto descriptors used by CREATE/ALTER PROTO BUNDLE statements.
    /// Contains a protobuf-serialized
    /// [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto).
    /// To generate it, [install](https://grpc.io/docs/protoc-installation/) and
    /// run `protoc` with --include_imports and --descriptor_set_out. For example,
    /// to generate for moon/shot/app.proto, run
    ///
    /// ```norust
    /// $protoc  --proto_path=/app_path --proto_path=/lib_path \
    ///          --include_imports \
    ///          --descriptor_set_out=descriptors.data \
    ///          moon/shot/app.proto
    /// ```
    ///
    /// For more details, see protobuffer [self
    /// description](https://developers.google.com/protocol-buffers/docs/techniques#self-description).
    pub proto_descriptors: ::bytes::Bytes,

    /// Optional. This field is exposed to be used by the Spanner Migration Tool.
    /// For more details, see
    /// [SMT](https://github.com/GoogleCloudPlatform/spanner-migration-tool).
    pub throughput_mode: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UpdateDatabaseDdlRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [database][crate::model::UpdateDatabaseDdlRequest::database].
    pub fn set_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.database = v.into();
        self
    }

    /// Sets the value of [statements][crate::model::UpdateDatabaseDdlRequest::statements].
    pub fn set_statements<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.statements = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [operation_id][crate::model::UpdateDatabaseDdlRequest::operation_id].
    pub fn set_operation_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.operation_id = v.into();
        self
    }

    /// Sets the value of [proto_descriptors][crate::model::UpdateDatabaseDdlRequest::proto_descriptors].
    pub fn set_proto_descriptors<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
        self.proto_descriptors = v.into();
        self
    }

    /// Sets the value of [throughput_mode][crate::model::UpdateDatabaseDdlRequest::throughput_mode].
    pub fn set_throughput_mode<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.throughput_mode = v.into();
        self
    }
}

impl wkt::message::Message for UpdateDatabaseDdlRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.UpdateDatabaseDdlRequest"
    }
}

/// Action information extracted from a DDL statement. This proto is used to
/// display the brief info of the DDL statement for the operation
/// [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl]: crate::client::DatabaseAdmin::update_database_ddl
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DdlStatementActionInfo {
    /// The action for the DDL statement, e.g. CREATE, ALTER, DROP, GRANT, etc.
    /// This field is a non-empty string.
    pub action: std::string::String,

    /// The entity type for the DDL statement, e.g. TABLE, INDEX, VIEW, etc.
    /// This field can be empty string for some DDL statement,
    /// e.g. for statement "ANALYZE", `entity_type` = "".
    pub entity_type: std::string::String,

    /// The entity name(s) being operated on the DDL statement.
    /// E.g.
    ///
    /// 1. For statement "CREATE TABLE t1(...)", `entity_names` = ["t1"].
    /// 1. For statement "GRANT ROLE r1, r2 ...", `entity_names` = ["r1", "r2"].
    /// 1. For statement "ANALYZE", `entity_names` = [].
    pub entity_names: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DdlStatementActionInfo {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [action][crate::model::DdlStatementActionInfo::action].
    pub fn set_action<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.action = v.into();
        self
    }

    /// Sets the value of [entity_type][crate::model::DdlStatementActionInfo::entity_type].
    pub fn set_entity_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.entity_type = v.into();
        self
    }

    /// Sets the value of [entity_names][crate::model::DdlStatementActionInfo::entity_names].
    pub fn set_entity_names<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.entity_names = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for DdlStatementActionInfo {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.DdlStatementActionInfo"
    }
}

/// Metadata type for the operation returned by
/// [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl]: crate::client::DatabaseAdmin::update_database_ddl
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UpdateDatabaseDdlMetadata {
    /// The database being modified.
    pub database: std::string::String,

    /// For an update this list contains all the statements. For an
    /// individual statement, this list contains only that statement.
    pub statements: std::vec::Vec<std::string::String>,

    /// Reports the commit timestamps of all statements that have
    /// succeeded so far, where `commit_timestamps[i]` is the commit
    /// timestamp for the statement `statements[i]`.
    pub commit_timestamps: std::vec::Vec<wkt::Timestamp>,

    /// Output only. When true, indicates that the operation is throttled e.g.
    /// due to resource constraints. When resources become available the operation
    /// will resume and this field will be false again.
    pub throttled: bool,

    /// The progress of the
    /// [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl]
    /// operations. All DDL statements will have continuously updating progress,
    /// and `progress[i]` is the operation progress for `statements[i]`. Also,
    /// `progress[i]` will have start time and end time populated with commit
    /// timestamp of operation, as well as a progress of 100% once the operation
    /// has completed.
    ///
    /// [google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl]: crate::client::DatabaseAdmin::update_database_ddl
    pub progress: std::vec::Vec<crate::model::OperationProgress>,

    /// The brief action info for the DDL statements.
    /// `actions[i]` is the brief info for `statements[i]`.
    pub actions: std::vec::Vec<crate::model::DdlStatementActionInfo>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UpdateDatabaseDdlMetadata {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [database][crate::model::UpdateDatabaseDdlMetadata::database].
    pub fn set_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.database = v.into();
        self
    }

    /// Sets the value of [statements][crate::model::UpdateDatabaseDdlMetadata::statements].
    pub fn set_statements<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.statements = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [commit_timestamps][crate::model::UpdateDatabaseDdlMetadata::commit_timestamps].
    pub fn set_commit_timestamps<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<wkt::Timestamp>,
    {
        use std::iter::Iterator;
        self.commit_timestamps = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [throttled][crate::model::UpdateDatabaseDdlMetadata::throttled].
    pub fn set_throttled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.throttled = v.into();
        self
    }

    /// Sets the value of [progress][crate::model::UpdateDatabaseDdlMetadata::progress].
    pub fn set_progress<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::OperationProgress>,
    {
        use std::iter::Iterator;
        self.progress = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [actions][crate::model::UpdateDatabaseDdlMetadata::actions].
    pub fn set_actions<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::DdlStatementActionInfo>,
    {
        use std::iter::Iterator;
        self.actions = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for UpdateDatabaseDdlMetadata {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata"
    }
}

/// The request for
/// [DropDatabase][google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase]: crate::client::DatabaseAdmin::drop_database
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DropDatabaseRequest {
    /// Required. The database to be dropped.
    pub database: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DropDatabaseRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [database][crate::model::DropDatabaseRequest::database].
    pub fn set_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.database = v.into();
        self
    }
}

impl wkt::message::Message for DropDatabaseRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.DropDatabaseRequest"
    }
}

/// The request for
/// [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl]: crate::client::DatabaseAdmin::get_database_ddl
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetDatabaseDdlRequest {
    /// Required. The database whose schema we wish to get.
    /// Values are of the form
    /// `projects/<project>/instances/<instance>/databases/<database>`
    pub database: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetDatabaseDdlRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [database][crate::model::GetDatabaseDdlRequest::database].
    pub fn set_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.database = v.into();
        self
    }
}

impl wkt::message::Message for GetDatabaseDdlRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.GetDatabaseDdlRequest"
    }
}

/// The response for
/// [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl]: crate::client::DatabaseAdmin::get_database_ddl
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetDatabaseDdlResponse {
    /// A list of formatted DDL statements defining the schema of the database
    /// specified in the request.
    pub statements: std::vec::Vec<std::string::String>,

    /// Proto descriptors stored in the database.
    /// Contains a protobuf-serialized
    /// [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto).
    /// For more details, see protobuffer [self
    /// description](https://developers.google.com/protocol-buffers/docs/techniques#self-description).
    pub proto_descriptors: ::bytes::Bytes,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetDatabaseDdlResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [statements][crate::model::GetDatabaseDdlResponse::statements].
    pub fn set_statements<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.statements = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [proto_descriptors][crate::model::GetDatabaseDdlResponse::proto_descriptors].
    pub fn set_proto_descriptors<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
        self.proto_descriptors = v.into();
        self
    }
}

impl wkt::message::Message for GetDatabaseDdlResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.GetDatabaseDdlResponse"
    }
}

/// The request for
/// [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations]: crate::client::DatabaseAdmin::list_database_operations
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListDatabaseOperationsRequest {
    /// Required. The instance of the database operations.
    /// Values are of the form `projects/<project>/instances/<instance>`.
    pub parent: std::string::String,

    /// An expression that filters the list of returned operations.
    ///
    /// A filter expression consists of a field name, a
    /// comparison operator, and a value for filtering.
    /// The value must be a string, a number, or a boolean. The comparison operator
    /// must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
    /// Colon `:` is the contains operator. Filter rules are not case sensitive.
    ///
    /// The following fields in the [Operation][google.longrunning.Operation]
    /// are eligible for filtering:
    ///
    /// * `name` - The name of the long-running operation
    /// * `done` - False if the operation is in progress, else true.
    /// * `metadata.@type` - the type of metadata. For example, the type string
    ///   for
    ///   [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]
    ///   is
    ///   `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`.
    /// * `metadata.<field_name>` - any field in metadata.value.
    ///   `metadata.@type` must be specified first, if filtering on metadata
    ///   fields.
    /// * `error` - Error associated with the long-running operation.
    /// * `response.@type` - the type of response.
    /// * `response.<field_name>` - any field in response.value.
    ///
    /// You can combine multiple expressions by enclosing each expression in
    /// parentheses. By default, expressions are combined with AND logic. However,
    /// you can specify AND, OR, and NOT logic explicitly.
    ///
    /// Here are a few examples:
    ///
    /// * `done:true` - The operation is complete.
    /// * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` \
    ///   `(metadata.source_type:BACKUP) AND` \
    ///   `(metadata.backup_info.backup:backup_howl) AND` \
    ///   `(metadata.name:restored_howl) AND` \
    ///   `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \
    ///   `(error:*)` - Return operations where:
    ///   * The operation's metadata type is
    ///     [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata].
    ///   * The database is restored from a backup.
    ///   * The backup name contains "backup_howl".
    ///   * The restored database's name contains "restored_howl".
    ///   * The operation started before 2018-03-28T14:50:00Z.
    ///   * The operation resulted in an error.
    ///
    /// [google.longrunning.Operation]: longrunning::model::Operation
    /// [google.spanner.admin.database.v1.RestoreDatabaseMetadata]: crate::model::RestoreDatabaseMetadata
    pub filter: std::string::String,

    /// Number of operations to be returned in the response. If 0 or
    /// less, defaults to the server's maximum allowed page size.
    pub page_size: i32,

    /// If non-empty, `page_token` should contain a
    /// [next_page_token][google.spanner.admin.database.v1.ListDatabaseOperationsResponse.next_page_token]
    /// from a previous
    /// [ListDatabaseOperationsResponse][google.spanner.admin.database.v1.ListDatabaseOperationsResponse]
    /// to the same `parent` and with the same `filter`.
    ///
    /// [google.spanner.admin.database.v1.ListDatabaseOperationsResponse]: crate::model::ListDatabaseOperationsResponse
    /// [google.spanner.admin.database.v1.ListDatabaseOperationsResponse.next_page_token]: crate::model::ListDatabaseOperationsResponse::next_page_token
    pub page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListDatabaseOperationsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListDatabaseOperationsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [filter][crate::model::ListDatabaseOperationsRequest::filter].
    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.filter = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListDatabaseOperationsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListDatabaseOperationsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListDatabaseOperationsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.ListDatabaseOperationsRequest"
    }
}

/// The response for
/// [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations]: crate::client::DatabaseAdmin::list_database_operations
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListDatabaseOperationsResponse {
    /// The list of matching database [long-running
    /// operations][google.longrunning.Operation]. Each operation's name will be
    /// prefixed by the database's name. The operation's
    /// [metadata][google.longrunning.Operation.metadata] field type
    /// `metadata.type_url` describes the type of the metadata.
    ///
    /// [google.longrunning.Operation]: longrunning::model::Operation
    /// [google.longrunning.Operation.metadata]: longrunning::model::Operation::metadata
    pub operations: std::vec::Vec<longrunning::model::Operation>,

    /// `next_page_token` can be sent in a subsequent
    /// [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations]
    /// call to fetch more of the matching metadata.
    ///
    /// [google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations]: crate::client::DatabaseAdmin::list_database_operations
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListDatabaseOperationsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [operations][crate::model::ListDatabaseOperationsResponse::operations].
    pub fn set_operations<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<longrunning::model::Operation>,
    {
        use std::iter::Iterator;
        self.operations = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListDatabaseOperationsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListDatabaseOperationsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.ListDatabaseOperationsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListDatabaseOperationsResponse {
    type PageItem = longrunning::model::Operation;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.operations
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// The request for
/// [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase]: crate::client::DatabaseAdmin::restore_database
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct RestoreDatabaseRequest {
    /// Required. The name of the instance in which to create the
    /// restored database. This instance must be in the same project and
    /// have the same instance configuration as the instance containing
    /// the source backup. Values are of the form
    /// `projects/<project>/instances/<instance>`.
    pub parent: std::string::String,

    /// Required. The id of the database to create and restore to. This
    /// database must not already exist. The `database_id` appended to
    /// `parent` forms the full database name of the form
    /// `projects/<project>/instances/<instance>/databases/<database_id>`.
    pub database_id: std::string::String,

    /// Optional. An encryption configuration describing the encryption type and
    /// key resources in Cloud KMS used to encrypt/decrypt the database to restore
    /// to. If this field is not specified, the restored database will use the same
    /// encryption configuration as the backup by default, namely
    /// [encryption_type][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type]
    /// = `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
    ///
    /// [google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type]: crate::model::RestoreDatabaseEncryptionConfig::encryption_type
    pub encryption_config: std::option::Option<crate::model::RestoreDatabaseEncryptionConfig>,

    /// Required. The source from which to restore.
    pub source: std::option::Option<crate::model::restore_database_request::Source>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl RestoreDatabaseRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::RestoreDatabaseRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [database_id][crate::model::RestoreDatabaseRequest::database_id].
    pub fn set_database_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.database_id = v.into();
        self
    }

    /// Sets the value of [encryption_config][crate::model::RestoreDatabaseRequest::encryption_config].
    pub fn set_encryption_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::RestoreDatabaseEncryptionConfig>,
    {
        self.encryption_config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [encryption_config][crate::model::RestoreDatabaseRequest::encryption_config].
    pub fn set_or_clear_encryption_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::RestoreDatabaseEncryptionConfig>,
    {
        self.encryption_config = v.map(|x| x.into());
        self
    }

    /// Sets the value of [source][crate::model::RestoreDatabaseRequest::source].
    ///
    /// Note that all the setters affecting `source` are mutually
    /// exclusive.
    pub fn set_source<
        T: std::convert::Into<std::option::Option<crate::model::restore_database_request::Source>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.source = v.into();
        self
    }

    /// The value of [source][crate::model::RestoreDatabaseRequest::source]
    /// if it holds a `Backup`, `None` if the field is not set or
    /// holds a different branch.
    pub fn backup(&self) -> std::option::Option<&std::string::String> {
        #[allow(unreachable_patterns)]
        self.source.as_ref().and_then(|v| match v {
            crate::model::restore_database_request::Source::Backup(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [source][crate::model::RestoreDatabaseRequest::source]
    /// to hold a `Backup`.
    ///
    /// Note that all the setters affecting `source` are
    /// mutually exclusive.
    pub fn set_backup<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.source = std::option::Option::Some(
            crate::model::restore_database_request::Source::Backup(v.into()),
        );
        self
    }
}

impl wkt::message::Message for RestoreDatabaseRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseRequest"
    }
}

/// Defines additional types related to [RestoreDatabaseRequest].
pub mod restore_database_request {
    #[allow(unused_imports)]
    use super::*;

    /// Required. The source from which to restore.
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Source {
        /// Name of the backup from which to restore.  Values are of the form
        /// `projects/<project>/instances/<instance>/backups/<backup>`.
        Backup(std::string::String),
    }
}

/// Encryption configuration for the restored database.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct RestoreDatabaseEncryptionConfig {
    /// Required. The encryption type of the restored database.
    pub encryption_type: crate::model::restore_database_encryption_config::EncryptionType,

    /// Optional. The Cloud KMS key that will be used to encrypt/decrypt the
    /// restored database. This field should be set only when
    /// [encryption_type][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type]
    /// is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form
    /// `projects/<project>/locations/<location>/keyRings/<key_ring>/cryptoKeys/<kms_key_name>`.
    ///
    /// [google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type]: crate::model::RestoreDatabaseEncryptionConfig::encryption_type
    pub kms_key_name: std::string::String,

    /// Optional. Specifies the KMS configuration for the one or more keys used to
    /// encrypt the database. Values are of the form
    /// `projects/<project>/locations/<location>/keyRings/<key_ring>/cryptoKeys/<kms_key_name>`.
    ///
    /// The keys referenced by kms_key_names must fully cover all
    /// regions of the database instance configuration. Some examples:
    ///
    /// * For single region database instance configs, specify a single regional
    ///   location KMS key.
    /// * For multi-regional database instance configs of type GOOGLE_MANAGED,
    ///   either specify a multi-regional location KMS key or multiple regional
    ///   location KMS keys that cover all regions in the instance config.
    /// * For a database instance config of type USER_MANAGED, please specify only
    ///   regional location KMS keys to cover each region in the instance config.
    ///   Multi-regional location KMS keys are not supported for USER_MANAGED
    ///   instance configs.
    pub kms_key_names: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl RestoreDatabaseEncryptionConfig {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [encryption_type][crate::model::RestoreDatabaseEncryptionConfig::encryption_type].
    pub fn set_encryption_type<
        T: std::convert::Into<crate::model::restore_database_encryption_config::EncryptionType>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.encryption_type = v.into();
        self
    }

    /// Sets the value of [kms_key_name][crate::model::RestoreDatabaseEncryptionConfig::kms_key_name].
    pub fn set_kms_key_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.kms_key_name = v.into();
        self
    }

    /// Sets the value of [kms_key_names][crate::model::RestoreDatabaseEncryptionConfig::kms_key_names].
    pub fn set_kms_key_names<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.kms_key_names = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for RestoreDatabaseEncryptionConfig {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig"
    }
}

/// Defines additional types related to [RestoreDatabaseEncryptionConfig].
pub mod restore_database_encryption_config {
    #[allow(unused_imports)]
    use super::*;

    /// Encryption types for the database to be restored.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum EncryptionType {
        /// Unspecified. Do not use.
        Unspecified,
        /// This is the default option when
        /// [encryption_config][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig]
        /// is not specified.
        ///
        /// [google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig]: crate::model::RestoreDatabaseEncryptionConfig
        UseConfigDefaultOrBackupEncryption,
        /// Use Google default encryption.
        GoogleDefaultEncryption,
        /// Use customer managed encryption. If specified, `kms_key_name` must
        /// must contain a valid Cloud KMS key.
        CustomerManagedEncryption,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [EncryptionType::value] or
        /// [EncryptionType::name].
        UnknownValue(encryption_type::UnknownValue),
    }

    #[doc(hidden)]
    pub mod encryption_type {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl EncryptionType {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::UseConfigDefaultOrBackupEncryption => std::option::Option::Some(1),
                Self::GoogleDefaultEncryption => std::option::Option::Some(2),
                Self::CustomerManagedEncryption => std::option::Option::Some(3),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("ENCRYPTION_TYPE_UNSPECIFIED"),
                Self::UseConfigDefaultOrBackupEncryption => {
                    std::option::Option::Some("USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION")
                }
                Self::GoogleDefaultEncryption => {
                    std::option::Option::Some("GOOGLE_DEFAULT_ENCRYPTION")
                }
                Self::CustomerManagedEncryption => {
                    std::option::Option::Some("CUSTOMER_MANAGED_ENCRYPTION")
                }
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for EncryptionType {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for EncryptionType {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for EncryptionType {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::UseConfigDefaultOrBackupEncryption,
                2 => Self::GoogleDefaultEncryption,
                3 => Self::CustomerManagedEncryption,
                _ => Self::UnknownValue(encryption_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for EncryptionType {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "ENCRYPTION_TYPE_UNSPECIFIED" => Self::Unspecified,
                "USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION" => {
                    Self::UseConfigDefaultOrBackupEncryption
                }
                "GOOGLE_DEFAULT_ENCRYPTION" => Self::GoogleDefaultEncryption,
                "CUSTOMER_MANAGED_ENCRYPTION" => Self::CustomerManagedEncryption,
                _ => Self::UnknownValue(encryption_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for EncryptionType {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::UseConfigDefaultOrBackupEncryption => serializer.serialize_i32(1),
                Self::GoogleDefaultEncryption => serializer.serialize_i32(2),
                Self::CustomerManagedEncryption => serializer.serialize_i32(3),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for EncryptionType {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<EncryptionType>::new(
                ".google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.EncryptionType",
            ))
        }
    }
}

/// Metadata type for the long-running operation returned by
/// [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase]: crate::client::DatabaseAdmin::restore_database
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct RestoreDatabaseMetadata {
    /// Name of the database being created and restored to.
    pub name: std::string::String,

    /// The type of the restore source.
    pub source_type: crate::model::RestoreSourceType,

    /// The progress of the
    /// [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase]
    /// operation.
    ///
    /// [google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase]: crate::client::DatabaseAdmin::restore_database
    pub progress: std::option::Option<crate::model::OperationProgress>,

    /// The time at which cancellation of this operation was received.
    /// [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
    /// starts asynchronous cancellation on a long-running operation. The server
    /// makes a best effort to cancel the operation, but success is not guaranteed.
    /// Clients can use
    /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
    /// other methods to check whether the cancellation succeeded or whether the
    /// operation completed despite cancellation. On successful cancellation,
    /// the operation is not deleted; instead, it becomes an operation with
    /// an [Operation.error][google.longrunning.Operation.error] value with a
    /// [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to
    /// `Code.CANCELLED`.
    ///
    /// [google.longrunning.Operation.error]: longrunning::model::Operation::result
    /// [google.rpc.Status.code]: rpc::model::Status::code
    pub cancel_time: std::option::Option<wkt::Timestamp>,

    /// If exists, the name of the long-running operation that will be used to
    /// track the post-restore optimization process to optimize the performance of
    /// the restored database, and remove the dependency on the restore source.
    /// The name is of the form
    /// `projects/<project>/instances/<instance>/databases/<database>/operations/<operation>`
    /// where the \<database\> is the name of database being created and restored to.
    /// The metadata type of the  long-running operation is
    /// [OptimizeRestoredDatabaseMetadata][google.spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata].
    /// This long-running operation will be automatically created by the system
    /// after the RestoreDatabase long-running operation completes successfully.
    /// This operation will not be created if the restore was not successful.
    ///
    /// [google.spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata]: crate::model::OptimizeRestoredDatabaseMetadata
    pub optimize_database_operation_name: std::string::String,

    /// Information about the source used to restore the database, as specified by
    /// `source` in
    /// [RestoreDatabaseRequest][google.spanner.admin.database.v1.RestoreDatabaseRequest].
    ///
    /// [google.spanner.admin.database.v1.RestoreDatabaseRequest]: crate::model::RestoreDatabaseRequest
    pub source_info: std::option::Option<crate::model::restore_database_metadata::SourceInfo>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl RestoreDatabaseMetadata {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::RestoreDatabaseMetadata::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [source_type][crate::model::RestoreDatabaseMetadata::source_type].
    pub fn set_source_type<T: std::convert::Into<crate::model::RestoreSourceType>>(
        mut self,
        v: T,
    ) -> Self {
        self.source_type = v.into();
        self
    }

    /// Sets the value of [progress][crate::model::RestoreDatabaseMetadata::progress].
    pub fn set_progress<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::OperationProgress>,
    {
        self.progress = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [progress][crate::model::RestoreDatabaseMetadata::progress].
    pub fn set_or_clear_progress<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::OperationProgress>,
    {
        self.progress = v.map(|x| x.into());
        self
    }

    /// Sets the value of [cancel_time][crate::model::RestoreDatabaseMetadata::cancel_time].
    pub fn set_cancel_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.cancel_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [cancel_time][crate::model::RestoreDatabaseMetadata::cancel_time].
    pub fn set_or_clear_cancel_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.cancel_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [optimize_database_operation_name][crate::model::RestoreDatabaseMetadata::optimize_database_operation_name].
    pub fn set_optimize_database_operation_name<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.optimize_database_operation_name = v.into();
        self
    }

    /// Sets the value of [source_info][crate::model::RestoreDatabaseMetadata::source_info].
    ///
    /// Note that all the setters affecting `source_info` are mutually
    /// exclusive.
    pub fn set_source_info<
        T: std::convert::Into<
                std::option::Option<crate::model::restore_database_metadata::SourceInfo>,
            >,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.source_info = v.into();
        self
    }

    /// The value of [source_info][crate::model::RestoreDatabaseMetadata::source_info]
    /// if it holds a `BackupInfo`, `None` if the field is not set or
    /// holds a different branch.
    pub fn backup_info(&self) -> std::option::Option<&std::boxed::Box<crate::model::BackupInfo>> {
        #[allow(unreachable_patterns)]
        self.source_info.as_ref().and_then(|v| match v {
            crate::model::restore_database_metadata::SourceInfo::BackupInfo(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [source_info][crate::model::RestoreDatabaseMetadata::source_info]
    /// to hold a `BackupInfo`.
    ///
    /// Note that all the setters affecting `source_info` are
    /// mutually exclusive.
    pub fn set_backup_info<T: std::convert::Into<std::boxed::Box<crate::model::BackupInfo>>>(
        mut self,
        v: T,
    ) -> Self {
        self.source_info = std::option::Option::Some(
            crate::model::restore_database_metadata::SourceInfo::BackupInfo(v.into()),
        );
        self
    }
}

impl wkt::message::Message for RestoreDatabaseMetadata {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata"
    }
}

/// Defines additional types related to [RestoreDatabaseMetadata].
pub mod restore_database_metadata {
    #[allow(unused_imports)]
    use super::*;

    /// Information about the source used to restore the database, as specified by
    /// `source` in
    /// [RestoreDatabaseRequest][google.spanner.admin.database.v1.RestoreDatabaseRequest].
    ///
    /// [google.spanner.admin.database.v1.RestoreDatabaseRequest]: crate::model::RestoreDatabaseRequest
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum SourceInfo {
        /// Information about the backup used to restore the database.
        BackupInfo(std::boxed::Box<crate::model::BackupInfo>),
    }
}

/// Metadata type for the long-running operation used to track the progress
/// of optimizations performed on a newly restored database. This long-running
/// operation is automatically created by the system after the successful
/// completion of a database restore, and cannot be cancelled.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct OptimizeRestoredDatabaseMetadata {
    /// Name of the restored database being optimized.
    pub name: std::string::String,

    /// The progress of the post-restore optimizations.
    pub progress: std::option::Option<crate::model::OperationProgress>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl OptimizeRestoredDatabaseMetadata {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::OptimizeRestoredDatabaseMetadata::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [progress][crate::model::OptimizeRestoredDatabaseMetadata::progress].
    pub fn set_progress<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::OperationProgress>,
    {
        self.progress = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [progress][crate::model::OptimizeRestoredDatabaseMetadata::progress].
    pub fn set_or_clear_progress<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::OperationProgress>,
    {
        self.progress = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for OptimizeRestoredDatabaseMetadata {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata"
    }
}

/// A Cloud Spanner database role.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DatabaseRole {
    /// Required. The name of the database role. Values are of the form
    /// `projects/<project>/instances/<instance>/databases/<database>/databaseRoles/<role>`
    /// where `<role>` is as specified in the `CREATE ROLE` DDL statement.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DatabaseRole {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DatabaseRole::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for DatabaseRole {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.DatabaseRole"
    }
}

/// The request for
/// [ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles]: crate::client::DatabaseAdmin::list_database_roles
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListDatabaseRolesRequest {
    /// Required. The database whose roles should be listed.
    /// Values are of the form
    /// `projects/<project>/instances/<instance>/databases/<database>`.
    pub parent: std::string::String,

    /// Number of database roles to be returned in the response. If 0 or less,
    /// defaults to the server's maximum allowed page size.
    pub page_size: i32,

    /// If non-empty, `page_token` should contain a
    /// [next_page_token][google.spanner.admin.database.v1.ListDatabaseRolesResponse.next_page_token]
    /// from a previous
    /// [ListDatabaseRolesResponse][google.spanner.admin.database.v1.ListDatabaseRolesResponse].
    ///
    /// [google.spanner.admin.database.v1.ListDatabaseRolesResponse]: crate::model::ListDatabaseRolesResponse
    /// [google.spanner.admin.database.v1.ListDatabaseRolesResponse.next_page_token]: crate::model::ListDatabaseRolesResponse::next_page_token
    pub page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListDatabaseRolesRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListDatabaseRolesRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListDatabaseRolesRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListDatabaseRolesRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListDatabaseRolesRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.ListDatabaseRolesRequest"
    }
}

/// The response for
/// [ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles]: crate::client::DatabaseAdmin::list_database_roles
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListDatabaseRolesResponse {
    /// Database roles that matched the request.
    pub database_roles: std::vec::Vec<crate::model::DatabaseRole>,

    /// `next_page_token` can be sent in a subsequent
    /// [ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles]
    /// call to fetch more of the matching roles.
    ///
    /// [google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles]: crate::client::DatabaseAdmin::list_database_roles
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListDatabaseRolesResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [database_roles][crate::model::ListDatabaseRolesResponse::database_roles].
    pub fn set_database_roles<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::DatabaseRole>,
    {
        use std::iter::Iterator;
        self.database_roles = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListDatabaseRolesResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListDatabaseRolesResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.ListDatabaseRolesResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListDatabaseRolesResponse {
    type PageItem = crate::model::DatabaseRole;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.database_roles
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// The request for
/// [AddSplitPoints][google.spanner.admin.database.v1.DatabaseAdmin.AddSplitPoints].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.AddSplitPoints]: crate::client::DatabaseAdmin::add_split_points
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AddSplitPointsRequest {
    /// Required. The database on whose tables/indexes split points are to be
    /// added. Values are of the form
    /// `projects/<project>/instances/<instance>/databases/<database>`.
    pub database: std::string::String,

    /// Required. The split points to add.
    pub split_points: std::vec::Vec<crate::model::SplitPoints>,

    /// Optional. A user-supplied tag associated with the split points.
    /// For example, "intital_data_load", "special_event_1".
    /// Defaults to "CloudAddSplitPointsAPI" if not specified.
    /// The length of the tag must not exceed 50 characters,else will be trimmed.
    /// Only valid UTF8 characters are allowed.
    pub initiator: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl AddSplitPointsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [database][crate::model::AddSplitPointsRequest::database].
    pub fn set_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.database = v.into();
        self
    }

    /// Sets the value of [split_points][crate::model::AddSplitPointsRequest::split_points].
    pub fn set_split_points<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::SplitPoints>,
    {
        use std::iter::Iterator;
        self.split_points = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [initiator][crate::model::AddSplitPointsRequest::initiator].
    pub fn set_initiator<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.initiator = v.into();
        self
    }
}

impl wkt::message::Message for AddSplitPointsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.AddSplitPointsRequest"
    }
}

/// The response for
/// [AddSplitPoints][google.spanner.admin.database.v1.DatabaseAdmin.AddSplitPoints].
///
/// [google.spanner.admin.database.v1.DatabaseAdmin.AddSplitPoints]: crate::client::DatabaseAdmin::add_split_points
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AddSplitPointsResponse {
    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl AddSplitPointsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }
}

impl wkt::message::Message for AddSplitPointsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.AddSplitPointsResponse"
    }
}

/// The split points of a table/index.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SplitPoints {
    /// The table to split.
    pub table: std::string::String,

    /// The index to split.
    /// If specified, the `table` field must refer to the index's base table.
    pub index: std::string::String,

    /// Required. The list of split keys, i.e., the split boundaries.
    pub keys: std::vec::Vec<crate::model::split_points::Key>,

    /// Optional. The expiration timestamp of the split points.
    /// A timestamp in the past means immediate expiration.
    /// The maximum value can be 30 days in the future.
    /// Defaults to 10 days in the future if not specified.
    pub expire_time: std::option::Option<wkt::Timestamp>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SplitPoints {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [table][crate::model::SplitPoints::table].
    pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.table = v.into();
        self
    }

    /// Sets the value of [index][crate::model::SplitPoints::index].
    pub fn set_index<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.index = v.into();
        self
    }

    /// Sets the value of [keys][crate::model::SplitPoints::keys].
    pub fn set_keys<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::split_points::Key>,
    {
        use std::iter::Iterator;
        self.keys = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [expire_time][crate::model::SplitPoints::expire_time].
    pub fn set_expire_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.expire_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [expire_time][crate::model::SplitPoints::expire_time].
    pub fn set_or_clear_expire_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.expire_time = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for SplitPoints {
    fn typename() -> &'static str {
        "type.googleapis.com/google.spanner.admin.database.v1.SplitPoints"
    }
}

/// Defines additional types related to [SplitPoints].
pub mod split_points {
    #[allow(unused_imports)]
    use super::*;

    /// A split key.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct Key {
        /// Required. The column values making up the split key.
        pub key_parts: std::option::Option<wkt::ListValue>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl Key {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [key_parts][crate::model::split_points::Key::key_parts].
        pub fn set_key_parts<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::ListValue>,
        {
            self.key_parts = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [key_parts][crate::model::split_points::Key::key_parts].
        pub fn set_or_clear_key_parts<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::ListValue>,
        {
            self.key_parts = v.map(|x| x.into());
            self
        }
    }

    impl wkt::message::Message for Key {
        fn typename() -> &'static str {
            "type.googleapis.com/google.spanner.admin.database.v1.SplitPoints.Key"
        }
    }
}

/// Indicates the dialect type of a database.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum DatabaseDialect {
    /// Default value. This value will create a database with the
    /// GOOGLE_STANDARD_SQL dialect.
    Unspecified,
    /// GoogleSQL supported SQL.
    GoogleStandardSql,
    /// PostgreSQL supported SQL.
    Postgresql,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [DatabaseDialect::value] or
    /// [DatabaseDialect::name].
    UnknownValue(database_dialect::UnknownValue),
}

#[doc(hidden)]
pub mod database_dialect {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl DatabaseDialect {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::GoogleStandardSql => std::option::Option::Some(1),
            Self::Postgresql => std::option::Option::Some(2),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => std::option::Option::Some("DATABASE_DIALECT_UNSPECIFIED"),
            Self::GoogleStandardSql => std::option::Option::Some("GOOGLE_STANDARD_SQL"),
            Self::Postgresql => std::option::Option::Some("POSTGRESQL"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for DatabaseDialect {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for DatabaseDialect {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for DatabaseDialect {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            1 => Self::GoogleStandardSql,
            2 => Self::Postgresql,
            _ => Self::UnknownValue(database_dialect::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for DatabaseDialect {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "DATABASE_DIALECT_UNSPECIFIED" => Self::Unspecified,
            "GOOGLE_STANDARD_SQL" => Self::GoogleStandardSql,
            "POSTGRESQL" => Self::Postgresql,
            _ => Self::UnknownValue(database_dialect::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for DatabaseDialect {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::GoogleStandardSql => serializer.serialize_i32(1),
            Self::Postgresql => serializer.serialize_i32(2),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for DatabaseDialect {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<DatabaseDialect>::new(
            ".google.spanner.admin.database.v1.DatabaseDialect",
        ))
    }
}

/// Indicates the type of the restore source.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum RestoreSourceType {
    /// No restore associated.
    TypeUnspecified,
    /// A backup was used as the source of the restore.
    Backup,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [RestoreSourceType::value] or
    /// [RestoreSourceType::name].
    UnknownValue(restore_source_type::UnknownValue),
}

#[doc(hidden)]
pub mod restore_source_type {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl RestoreSourceType {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::TypeUnspecified => std::option::Option::Some(0),
            Self::Backup => std::option::Option::Some(1),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::TypeUnspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
            Self::Backup => std::option::Option::Some("BACKUP"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for RestoreSourceType {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for RestoreSourceType {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for RestoreSourceType {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::TypeUnspecified,
            1 => Self::Backup,
            _ => Self::UnknownValue(restore_source_type::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for RestoreSourceType {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "TYPE_UNSPECIFIED" => Self::TypeUnspecified,
            "BACKUP" => Self::Backup,
            _ => Self::UnknownValue(restore_source_type::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for RestoreSourceType {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::TypeUnspecified => serializer.serialize_i32(0),
            Self::Backup => serializer.serialize_i32(1),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for RestoreSourceType {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<RestoreSourceType>::new(
            ".google.spanner.admin.database.v1.RestoreSourceType",
        ))
    }
}
